相同的範圍分配IP我在玩碼頭。現在我想將IP分配給與我的主機操作系統具有相同IP範圍的容器。碼頭工人。從主機
我的主機有IP地址192.168.1.50(192.168.1.0/24網絡)。我想用Docker容器的相同網絡中的192.168.1.51作爲例子。
對於這個I`ve安裝橋utils的(我使用Ubuntu 14.04)和重新配置我的接口:
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet static
address 192.168.1.50
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
現在我有這樣的配置:
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
link/ether 08:00:27:a5:22:5d brd ff:ff:ff:ff:ff:ff
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 56:84:7a:fe:97:99 brd ff:ff:ff:ff:ff:ff
inet 172.17.42.1/16 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::5484:7aff:fefe:9799/64 scope link
valid_lft forever preferred_lft forever
4: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 08:00:27:a5:22:5d brd ff:ff:ff:ff:ff:ff
inet 192.168.1.50/24 brd 192.168.0.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fea5:225d/64 scope link
valid_lft forever preferred_lft forever
如何建立每個新具有與主機相同的IP範圍192.168.1.0/24的IP的碼頭工人?如何爲每個新的碼頭集裝箱指定使用br0界面?
我還沒有嘗試過,但我認爲這大致是docker run參數'--net = host'的作用。 –
這與http://stackoverflow.com/questions/35742807/docker-1-10-containers-ip-in-lan和http://stackoverflow.com/questions/22641828/how-to-set-a -docker-containers-ip?lq = 1 – Dreamcat4