In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to establish Docker bridging network in Centos7, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Why let docker bridge the physical network?
Docker provides an isolated private network environment by default. At startup, a virtual network card of docker0 is established, and each container is connected to the docker0 network card. The ip segment of docker0 is 172.17.0.1. If you want the container to be accessed by other machines in the same network segment as the host, you must map a port to the port of the host when you start docker, for example: docker run-itd-p 22 centos. This is unacceptable to us, thinking that every application has to rack its brains to set ports, because it can not be repeated, and it is even more unimaginable if the application has multiple ports. So in order to make the container and the host on the same network segment, we need to set up our own bridging network.
The process of establishing a Docker bridging physical network on a centos7 host host Nic information: name:ens0IP:192.168.184.99GATEWAY:192.168.184.2DNS:192.168.184.2
1. Stop the docker service
~ #: service docker stop
two。 Delete the docker0 network card
~ #: ip link set dev docker0 down~#:brctl delbr docker0
3. Create a new bridge physical network virtual network card br0
~ #: brctl addbr br0~#:ip link set dev br0 up~#:ip addr add 192.168.184.100 dev br0 24 dev br0 # assigns the ip address in the physical network to br0 ~ #: ip addr del 192.168.184.99 ~ dev ens0 # empties the IP of the host network card ~ #: brctl addif br0 ens0 # hangs the host network card on the br0 ~ #: ip route del default # deletes the original route ~ #: ip route add default via 192.168.184.2 dev br0 # sets the route for br0
4. Set docker service startup parameters
It should be noted here that the configuration files of different linux operating systems docker are different.
Centos in / etc/sysconfig/docker
For other operating systems, please go to the following URL
Https://docs.docker.com/installation/#installation
~ #: vim / etc/sysconfig/docker # is modified to OPTIONS='--selinux-enabled-breadbr0' in the OPTIONS='--selinux-enabled' line, that is, br0 network card is used for bridging when the docker service is started.
5. Start the docker service
~ #: service docker start
6. Install pipework
~ #: git clone https://github.com/jpetazzo/pipework~#:cp ~ / pipework/pipework / usr/local/bin/
7. Start a container that sets up the network manually
It is best not to let docker acquire ip automatically. The next startup will change and the automatically acquired ip may conflict with the ip in the physical network segment.
~ #: docker run-itd-net=none-name=test centos7 / bin/bash
9. Set up an ip@ gateway for the test container with the same address segment as the bridged physical network
~ #: pipework br0 test 192.168.184.11Universe 192.168.184.2
10. Enter the container to view ip
~ #: docker attach test shares here on how to build a Docker bridging network in Centos7. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.