创建子网
docker network create --driver bridge --subnet 172.18.0.0/24 --gateway 172.18.0.1 子网名称
创建docker的时候需要连接到已有子网
services:
服务名称:
command: 'bash -c "" '
image:
container_name:
restart: always
volumes:
-
ports:
-
working_dir:
networks:
子网名字:
ipv4_address: "设置.子网.ip.地址"
networks:
# default:
# external:
# name: 子网名称
子网名称:
external: true
如果要新建子网,那就不用分两步了,可以把新增网络写到yaml里
services:
服务名称:
command: 'bash -c "" '
image:
container_name:
restart: always
volumes:
-
ports:
-
working_dir:
networks:
子网名称:
ipv4_address: "设置.子网.ip.地址"
networks:
子网名称:
driver: bridge