docker-compose 启动yaml有时可能的容器网段与宿主机的ip冲突导致宿主机上不了网,这时候可以更改yaml指定subnet
宿主机内网一般是192**,这时候容器可以指定172*
version: '3.9'
services:
coredns:
image: coredns/coredns:1.10.0
container_name: coredns
ports:
- 53:53/udp
networks:
mynetwork:
ipv4_address: 172.28.0.4
volumes:
- ./coredns/hostsfile:/etc/coredns/hostsfile
- ./coredns/Corefile:/Corefile
networks:
mynetwork1:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
gateway: 172.28.0.1