In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
What the editor wants to share with you this time is what the four network types of Docker are. The article is rich in content. Interested friends can learn about it. I hope you can get something after reading this article.
Four types of networks:
None: do not configure any network function for the container.-- net=noneContainer: share Network Namespace,--net=container:containerID (K8S) Host with another running container: NAT network model designed to share Network Namespace,--net=hostBridge:Docker with host
The following are explained separately:
None:
[root@docker1 centos_zabbix] # docker run-it-- network none centos6.9_ssh:v2 / bin/bash [root@6ae597015723 /] # ip addr1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 0000VlV 0000VlV 0000Rd 00VOO brd 0000LV 00VOO 00LV 00VOO 00 inet 127.0.0.1and 8 scope host lo valid_lft forever preferred_lft forever
Without ip, you can play freely in the container. It doesn't make much sense.
Container type of network:
[root@1c21de6080bb html] # [root@docker1 centos_zabbix] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES1c21de6080bb centos6.9_nginx_ssh:v3 "/ bin/bash" 26 seconds ago Up 25 seconds vigorous_ payne [root @ docker1 centos_zabbix] # docker run-it-network container:1c21de6080bb centos6.9_nginx_ssh:v4 / bin/bash share the ip address of the hostname You can view the attribute [root@docker1 centos_zabbix] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES41c457f6b89d centos6.9_nginx_ssh:v4 "/ bin/bash" 5 minutes ago Up 5 minutes loving_curie1c21de6080bb centos6.9_nginx_ssh:v3 "/ bin/bash" 6 minutes ago Up 6 minutes vigorous_payne [root@docker1 centos_zabbix] # docker inspect 41c457f6b89d | grep-I network "NetworkMode": "container:1c21de6080bb8c83e800fa8b5fb15782a18bb61ab292050ca1172fbb866b1afc" "NetworkSettings": {"Networks": {}
It should be noted that the port of this public container type is occupied by the one who uses a certain port first, and later cannot use this port.
Host Typ
[root@docker1 centos_zabbix] # docker run-it-- network=host centos6.9_nginx_ssh:v2 / bin/bash
This kind of port is shared with the host, and the one who uses it first has the highest performance, so we use this parameter when building the image, in order to unify the network type and improve the efficiency of building the image.
After reading this article about what the four types of Docker networks are, if you think the article is well written, you can share it with more people.
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.