Centos 6 Docker Configuration Bridge Network

Source: Internet
Author: User
Tags dns2 uuid

To make it easier for machines and Docker containers in the local network to communicate, we often have the need to configure the Docker container to the same network segment as the host. This requirement is actually very easy to achieve, we simply will Docker container and host network card Bridge, and then to Docker containers with IP on it.

Centos 6 Follow the method below (6 and 7 are different)

[Root@localhost ~]# cd/etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-eth0   Ifdown-ib    ifdown-ppp     ifup-aliases  ifup-ipv6
ifup-ppp     Init.ipv6-global IFDOWN-IPPP  ifdown-routes  ifup-bnep     ifup-isdn   ifup-routes
net.hotplug       Ifdown-ipv6  ifdown-sit     ifup-eth      ifup-plip       ifup-sit
network-functions IFDOWN-BNEP  ifdown-isdn  ifdown-tunnel  ifup-ib       ifup-plusb    Ifup-tunnel Network-functions-ipv6
ifdown-eth   ifdown-post  ifup           ifup-ippp   ifup-post Ifup-wireless
[root@localhost network-scripts]# CP Ifcfg-eth0 IFCFG-BR0
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8-9
[Root@localhost network-scripts]# VI ifcfg-eth0
device=eth0
hwaddr=00:0c:29:db:b2:28
TYPE=Ethernet
uuid=b2268aab-fa2e-49e9-bd67-2572f29e5790
Onboot=yes
nm_controlled=yes
bootproto=static
ipaddr=192.168.1.179
netmask=255.255.255.0
gateway=192.168.1.1
dns1=114.114.114.114
dns2=8.8.4.4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7 8 9 10 11 12 13-14

Add Bridge=br0, delete ipaddr, NETMASK, GATEWAY, DNS

Device=eth0
hwaddr=00:0c:29:db:b2:28
type=ethernet
uuid=b2268aab-fa2e-49e9-bd67-2572f29e5790
Onboot=yes
bridge=br0
bootproto=none
#IPADDR =192.168.1.179
#NETMASK =255.255.255.0
#GATEWAY =192.168.1.1
#DNS1 =114.114.114.114
#DNS2 =8.8.4.4
1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 3 4 5 6 7 8 9 10 11 The 12 13

Save exit

[Root@localhost network-scripts]# VI ifcfg-br0
device=eth0
hwaddr=00:0c:29:db:b2:28
TYPE=Ethernet
uuid=b2268aab-fa2e-49e9-bd67-2572f29e5790
Onboot=yes
nm_controlled=yes
bootproto=static
ipaddr=192.168.1.179
netmask=255.255.255.0
gateway=192.168.1.1
dns1=114.114.114.114
dns2=8.8.4.4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 5 6 7 8 9 10 11 12 13-14

Modify device to Br0,type for Bridge, set the Eth0 network settings here

Device=br0
type=bridge
onboot=yes
bootproto=static
ipaddr=192.168.1.179
netmask= 255.255.255.0
gateway=192.168.1.1
dns1=114.114.114.114
dns2=8.8.4.4
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9-10

Save exit

[Root@localhost network-scripts]# Service Network restart
1 1

I have a problem with this step, but it's OK to reboot the host.

[Root@localhost ~]# ifconfig br0 Link encap:ethernet hwaddr 00:0c:29:db:b2:28 inet addr:192.168.1.179 Bc ast:192.168.1.255 mask:255.255.255.0 inet6 addr:fe80::20c:29ff:fedb:b228/64 scope:link up BROADCAST
          RUNNING multicast mtu:1500 metric:1 RX packets:137 errors:0 dropped:0 overruns:0 frame:0
          TX packets:93 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 RX bytes:13745 (13.4 KiB) TX bytes:11095 (10.8 KiB) Docker0 Link encap:ethernet hwaddr c6:01:70:af:c6:e4 in
          ET addr:172.17.42.1 bcast:0.0.0.0 mask:255.255.0.0 inet6 addr:fe80::c401:70ff:feaf:c6e4/64 Scope:Link
          Up broadcast RUNNING multicast mtu:1500 metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 RX bytes:0  (0.0 b) TX bytes:468 (468.0 b) eth0 Link encap:ethernet HWAddr 00:0c:29:db:b2:28 Inet6 addr:fe80::20c:29ff:fedb:b228/64 scope:link up broadcast RUNNING Multica
          ST mtu:1500 metric:1 RX packets:137 errors:0 dropped:0 overruns:0 TX packets:101 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:15663 (15
          2 KiB) TX bytes:11959 (11.6 KiB) Lo Link encap:local loopback inet addr:127.0.0.1 mask:255.0.0.0  Inet6
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.