1、创建网络
docker network create -d bridge mynetwork
2、配置 docker-compose.yml的network
docker-compose1.yml
-
version: "3"
-
services:
-
redis:
-
image: redis:5.0.3
-
container_name: redis
-
networks:
-
- default
-
- mynetwork
-
mysql:
-
image: mysql:5.7
-
container_name: mysql
-
networks:
-
- default
-
- mynetwork
-
networks:
-
mynetwork:
-
external: true
docker-compose2.yml
-
version: "3"
-
services:
-
php:
-
image: php:7.1
-
container_name: php
-
networks:
-
- default
-
- mynetwork
-
external_links:
-
- redis
-
- mysql
-
networks:
-
mynetwork:
-
external: true