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