Docker의 네 가지 네트워크 모델
3467 단어 DockerK8S&Docker
NAT , , NAT , NAT
2. None(네트워크 없음)
:docker run --net=none
[root@docker ~]# docker run --rm -ti --net=none centos:centos7
3. Host(호스트와 동일한 IP)
:docker run --net=host
[root@docker ~]# docker run --rm -ti --net=Host centos:centos7
[root@docker /]# ifconfig
docker0: 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 0
ens192: 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 (37.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: 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.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
넷째, 연합 네트워크(즉 두 용기가 하나의 IP 주소를 공유함)
-----
[root@docker ~]# docker run --rm -ti centos:centos7 # nat
[root@2f504d6966dc /]# ifconfig
eth0: flags=4163 mtu 1500
inet 172.7.5.2 netmask 255.255.255.0 broadcast 172.7.5.255 #IP172.7.5.2
ether 02:42:ac: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
,
-----
:Docker run —net=container:${container_id}
[root@docker ~]# docker ps # ID
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2f504d6966dc 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 /]# ifconfig
eth0: flags=4163 mtu 1500
inet 172.7.5.2 netmask 255.255.255.0 broadcast 172.7.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 0
lo: 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.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
첫 번째 Docker for Mac참고 , 나는 옆에 있는 Mac에 Docker를 설치하고 컨테이너를 세워 보고 싶다. Docker Hub를 처음 사용할 때는 계정을 만들어야 합니다. Docker.dmg을 실행하면 Docker가 설치됩니다. Dock...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.