Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Four Network models of Docker

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. NAT (default) NAT network model, which is NAT mode by default For example, the port mapping of a network is in Nat II, None (no network) format: docker run-- net=none [root@docker ~] # docker run-- rm-ti-- net=none centos:centos7 III. Host (same IP as host) format: docker run-- net=host [root@docker ~] # docker run-- rm-ti-- net=Host centos:centos7 [root@docker /] # ifconfigdocker0: flags=4099 mtu 1500 inet 172.7.5.1 netmask 255.255.255.0 broadcast 172.7.5.255 inet6 fe80::42:28ff:fe56:8b6 prefixlen 64 scopeid 0x20 ether 02:42:28:56:08:b6 txqueuelen 0 (Ethernet) RX Packets 135990 bytes 9017234 (8.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 158771 bytes 317188403 (302.4 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens192: flags=4163 mtu 1500 inet 10.3.153.120 netmask 255.255.255.0 broadcast 10.3.153.255 inet6 fe80::36aa:b367:aa13:b475 prefixlen 64 scopeid 0x20 ether 00:50:56:9b:00:06 txqueuelen 1000 ( Ethernet) RX packets 747539 bytes 528246025 (503.7 MiB) RX errors 0 dropped 1227 overruns 0 frame 0 TX packets 249250 bytes 38867074 (MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6:: 1 prefixlen 128 scopeid 0x10 loop txqueuelen 1 (Local Loopback) RX packets 0 bytes 0 (0.0B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0. Federated network (i.e. two containers share an IP address) the first container runs-[root@docker ~] # docker run-- rm-ti centos:centos7 # launches a container [root@2f504d6966dc /] # ifconfigeth0: flags=4163 mtu 1500 inet 172.7.5.2 netmask 255.255.255.0 broadcast 172.5.255 # IP172.7.5.2 ether 02:42:ac in nat mode: 07:05:02 txqueuelen 0 (Ethernet) RX packets 7417 bytes 13726936 (13.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 6118 bytes 473182 (462.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 second container runs In the form of federated network-format: Docker run-net=container:$ {container_id} [root@docker ~] # docker ps # View the ID value of the first container CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES2f504d6966dc centos:centos7 "/ bin/bash" 6 minutes ago Up 6 Minutes thirsty_ bhabha [root @ docker ~] # docker run-- rm-ti-- net=container:2f504d6966dc centos:centos7 [root@2f504d6966dc /] # ifconfigeth0: flags=4163 mtu 1500 inet 172.7.5.2 netmask 255.255.255.0 broadcast 172.5.255 ether 02:42:ac:07:05:02 txqueuelen 0 (Ethernet) RX packets 15431 bytes 27381590 (26.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13359 bytes 1061065 (1.0 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 loop txqueuelen 1 (Local Loopback) RX packets 0 bytes 0 (0.0B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report