Docker-如何避免网桥IP?

时间:2018-07-19 12:10:32

标签: docker docker-compose

Docker正在br-80db19b2a6a0接口上采用IP 172.19.0.1。我想避免使用此ip,因为它映射到我们的邮件服务器。

这些是接口(Linux机器):

br-096c79c68bb1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        inet6 fe80::42:94ff:feb0:6dc9  prefixlen 64  scopeid 0x20<link>
        ether 02:42:94:b0:6d:c9  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 106  bytes 14176 (14.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

br-80db19b2a6a0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.19.0.1  netmask 255.255.0.0  broadcast 172.19.255.255
        inet6 fe80::42:f3ff:fe4e:f91  prefixlen 64  scopeid 0x20<link>
        ether 02:42:f3:4e:0f:91  txqueuelen 0  (Ethernet)
        RX packets 466  bytes 18568 (18.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 515  bytes 40663 (40.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.1.5  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 02:42:dc:23:25:46  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.17.167  netmask 255.255.255.0  broadcast 172.18.17.255
        inet6 fe80::f68e:38ff:fefe:6cfd  prefixlen 64  scopeid 0x20<link>
        ether f4:8e:38:fe:6c:fd  txqueuelen 1000  (Ethernet)
        RX packets 1436  bytes 1254171 (1.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 818  bytes 125043 (125.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 20  memory 0xee080000-ee0a0000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Loopback Local)
        RX packets 3553  bytes 365530 (365.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3553  bytes 365530 (365.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

我该怎么办?

1 个答案:

答案 0 :(得分:0)

“使用--network标志启动容器时,可以使用--ip或--ip6标志指定分配给该网络上的容器的IP地址。”

在这里看看: https://docs.docker.com/config/containers/container-networking/#dns-services