In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. Interconnection between Docker containers
Docker has now become a lightweight virtualization solution, where all containers can be interconnected through a bridge under the same host. If you have previous experience with docker, you may be used to using-link to interconnect containers. With the gradual improvement of docker, it is highly recommended that you use bridge to interconnect containers.
II. Practical process
1. Create a network my-net:
[root@ChatDevOps ~] # docker network create my-net71b42506de62797889372ea4a5270f905f79a19cf80e308119c02e529b89c94e [root@ChatDevOps ~] # docker network lsNETWORK ID NAME DRIVER SCOPE3dec5cbb852e bridge bridge local6dd6dcfc2f26 host host local71b42506de62 my-net bridge local4c142a02cd6b none null local
two。 Specify the bridging network when creating the docker container:
[root@ChatDevOps docker] # docker create-it-- name D1-- network my-net-p 8080 it 80 ubuntu:14.044776b65db566f370cad5da3a9354a12c7e4f9badab53647b7e30e1e8f343ae3d [root@ChatDevOps docker] # docker start d1d1
In this command, docker create can also use docker container create, which is equivalent. -name specifies the name of the container,-network specifies the network name of the container, the bridge form defaults to bridge, and-p or-publish specifies the mapped port. If the network specified in this step is not created in advance, the container will not start properly. At this point, you can create a network for the container and start the container again.
3. You can also specify a network that has been created when running a docker container:
[root@ChatDevOps docker] # docker run-it-- name D2-- network my-net-- publish 8081 name 80 ubuntu:14.04 / bin/bashroot@07fd516911d0:/# ping d1PING D1 (172.18.0.2) 56 (84) bytes of data.64 bytes from d1.my-net (172.18.0.2): icmp_seq=1 ttl=64 time=0.115 msroot@4776b65db566:/# ping d2PING D2 (172.18.0.3) 56 (84) bytes of data.64 bytes from d2.my-net (172.18.0.3): icmp_seq=1 ttl=64 time=0.062 ms
Containers that are connected to the same bridge can be ping by container name. You can also ping its IP directly.
III. Summary
1. After the docker installation is complete, the docker container has three networks, as follows:
[root@ChatDevOps ~] # docker network lsNETWORK ID NAME DRIVER SCOPE3dec5cbb852e bridge bridge local6dd6dcfc2f26 host host local4c142a02cd6b none null local
two。 All container networks in the same network are interoperable.
3. The dns configuration in the network configuration of the container can be configured in the / etc/docker/daemon.json file of the host, according to the official format:
{"bip": "192.168.1.5lap24", "fixed-cidr": "192.168.1.5lap25", "fixed-cidr-v6": "2001:db8::/64", "mtu": 1500, "default-gateway": "10.20.1.1", "default-gateway-v6": "2001:db8:abcd::89", "dns": ["10.20.1.2" "10.20.1.3"]}
It can be configured according to the actual situation.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
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.