四十四、Docker-网络模式
1、概述
Docker默认提供了一个隔离的内网环境,启动时会建立一个docker0的虚拟网卡,每个容器都是连接到docker0网卡上的,docker0的ip为172.17.0.1。
基于Docker run创建Docker容器时,可以使用–net选项指定容器的网络模式,Docker默认有以下四种网络模式:
host模式,使用–net=host指定;
container模式,使用–net=container:NAME_or_ID指定;
none模式,使用–net=none指定;
bridge模式,使用–net=bridge指定,默认设置;
2、Host模式详解
默认Docker容器运行会分配独立的Network Namespace隔离子系统,基于host模式,容器将不会获得一个独立的Network Namespace,而是和宿主机共用一个Network Namespace,容器将不会虚拟出自己的网卡,配置自己的IP等,而是使用宿主机的IP和端口。网络通信性能较好,不需要进行网络转发,即不存在网络损耗,但是和宿主机之间不好区分。
验证:
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos7-ssh latest 45ef6218ff65 46 hours ago 672 MB
nginx latest 5a3221f0137b 7 months ago 126 MB
docker.io/ansible/centos7-ansible latest 688353a31fde 3 years ago 447 MB
[root@localhost ~]# docker run -itd --net=host centos7-ssh:latest
a465e94ef9e1ac4ecf0e9b8ec569b55b2ad4ffa2f39fc76dfab443bae4830624
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a465e94ef9e1 centos7-ssh:latest "/bin/sh -c /usr/s..." About a minute ago Up About a minute admiring_bohr
[root@localhost ~]# docker exec -it a465e94ef9e1
[root@localhost ~]# docker exec -it a465e94ef9e1 /bin/bash
# 共享宿主机网络
[root@localhost ansible]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0inet6 fe80::42:8aff:fedb:f65 prefixlen 64 scopeid 0x20<link>ether 02:42:8a:db:0f:65 txqueuelen 0 (Ethernet)RX packets 30 bytes 2064 (2.0 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 8 bytes 656 (656.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.0.151 netmask 255.255.255.0 broadcast 10.0.0.255inet6 fe80::773:49d0:5ac7:b300 prefixlen 64 scopeid 0x20<link>ether 00:0c:29:85:4e:cc txqueuelen 1000 (Ethernet)RX packets 1480 bytes 161740 (157.9 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 982 bytes 139835 (136.5 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0# 宿主机22端口被占用,修改容器端口以保证不冲突
[root@localhost ansible]# vi /etc/ssh/sshd_config port=6022[root@localhost ansible]# /usr/sbin/sshd
[root@localhost ansible]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6022 0.0.0.0:* LISTEN 50/sshd
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN -
tcp6 0 0 :::6022 :::* LISTEN 50/sshd
3、Container模式详解
Container模式指定新创建的容器和已经存在的一个容器共享一个Network Namespace,而不是和宿主机共享。即新创建的容器不会创建自己的网卡,配置自己的IP,而是和一个指定的容器共享IP、端口范围等。同样两个容器除了网络方面相同之外,其他的如文件系统、进程列表等还是隔离的。
验证:
[root@localhost ~]# docker ps -aq|xargs docker rm -f
a465e94ef9e1
# 启动第一个容器
[root@localhost ~]# docker run -itd centos7-ssh
2908c6be2ba68a5016d812fff608101aa28cfa250af31240bef596f4b624e05e
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2908c6be2ba6 centos7-ssh "/bin/sh -c /usr/s..." 9 seconds ago Up 8 seconds 22/tcp, 80/tcp festive_visvesvaraya
[root@localhost ~]# docker inspect 2908c6be2ba6 |grep -i ipaddr|tail -1"IPAddress": "172.17.0.2",# 启动第二个容器,和第一个容器IP相同
[root@localhost ~]# docker run -itd --net=container:2908c6be2ba6 centos7-ssh
8e3e103b5756513a7c4471613c50755e053a7619586d062988f13bc411923342
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8e3e103b5756 centos7-ssh "/bin/sh -c /usr/s..." 4 seconds ago Up 3 seconds mystifying_turing
2908c6be2ba6 centos7-ssh "/bin/sh -c /usr/s..." 3 minutes ago Up 3 minutes 22/tcp, 80/tcp festive_visvesvaraya
[root@localhost ~]# docker exec -it 8e3e103b5756 /bin/bash
[root@2908c6be2ba6 ansible]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 172.17.0.2 netmask 255.255.0.0 broadcast 0.0.0.0inet6 fe80::42:acff:fe11:2 prefixlen 64 scopeid 0x20<link>ether 02:42:ac:11:00:02 txqueuelen 0 (Ethernet)RX packets 8 bytes 656 (656.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 8 bytes 656 (656.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
4、None模式详解
None模式与其他的模式都不同,如果处于None模式,Docker容器拥有自己的Network Namespace,但是并不为Docker容器进行任何网络配置。也就是说该Docker容器没有网卡、IP、路由等信息,需要手工为Docker容器添加网卡、配置IP等,使用Pipework工具为Docker容器指定IP等信息。
验证:
# none模式启动后容器没有IP
[root@localhost ~]# docker run -itd --net=none centos7-ssh
118d674eed26031fe50d2e8c3884ff09b273f6a34806941db16b4f186e98bf1a
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
118d674eed26 centos7-ssh "/bin/sh -c /usr/s..." 5 seconds ago Up 5 seconds flamboyant_poitras
[root@localhost ~]# docker exec -it 118d674eed26 /bin/bash
[root@118d674eed26 ansible]# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
自定义容器 IP
# 下载 pipework 脚本
[root@localhost ~]# git clone https://github.com/jpetazzo/pipework
[root@localhost ~]# mv pipework /usr/local/sbin
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ce0886620956 centos7-ssh "/bin/sh -c /usr/s..." 2 seconds ago Up 1 second 22/tcp, 80/tcp hardcore_saha
# 配置 IP ,pipework + 桥接网卡 + 容器ID + 定义的IP/掩码位数@网关(可以直接配置为物理机网关)
[root@localhost ~]# pipework br0 ce0886620956 10.0.0.159/24@10.0.0.2
[root@localhost ~]# docker exec -it ce0886620956 /bin/bash
[root@ce0886620956 ansible]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.2 0.0.0.0 UG 0 0 0 eth1
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 eth0[root@ce0886620956 ansible]# ifconfigeth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.0.159 netmask 255.255.255.0 broadcast 10.0.0.255inet6 fe80::c4f4:2cff:fe25:d339 prefixlen 64 scopeid 0x20<link>ether c6:f4:2c:25:d3:39 txqueuelen 1000 (Ethernet)RX packets 17 bytes 1989 (1.9 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 14 bytes 1094 (1.0 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
5、Bridge模式详解
Bridge模式是Docker默认的网络模式,该模式会为每一个容器分配Network Namespace、设置IP、路由等配置,默认会将Docker容器连接到一个虚拟网桥交换机Docker0上。
桥接模式拓扑图:
Docker Bridge创建过程:
- 首先宿主机上创建一对虚拟网卡veth pair设备,veth设备总是成对出现的,组成了一个数据的通道,数据从一个设备进入,就会从另一个设备出来,veth设备常用来连接两个网络设备。
- Docker将veth pair设备的一端放在新创建的容器中,并命名为eth0,然后将另一端放在宿主机中,以vethxxx这样类似的名字命名,并将这个网络设备加入到docker0网桥中,可以通过brctl show命令查看。
- 从docker0子网中分配一个IP给容器使用,并设置docker0的IP地址为容器的默认网关。
- 此时容器IP与宿主机能够通信,宿主机也可以访问容器中的IP地址,在Bridge模式下,连在同一网桥上的容器之间可以相互通信,同时容器也可以访问外网,但是其他物理机不能访问docker容器IP,需要通过NAT将容器IP的port映射为宿主机的IP和port。
验证:
[root@localhost ~]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0ether 02:42:59:da:d5:8c txqueuelen 0 (Ethernet)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.0.151 netmask 255.255.255.0 broadcast 10.0.0.255inet6 fe80::773:49d0:5ac7:b300 prefixlen 64 scopeid 0x20<link>ether 00:0c:29:85:4e:cc txqueuelen 1000 (Ethernet)RX packets 247 bytes 33738 (32.9 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 176 bytes 20329 (19.8 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos7-ssh latest 45ef6218ff65 4 days ago 672 MB
nginx latest 5a3221f0137b 7 months ago 126 MB
docker.io/ansible/centos7-ansible latest 688353a31fde 3 years ago 447 MB
[root@localhost ~]# docker run -itd centos7-ssh
31f922e8b93dde32d3ee793fa881ba673e6aea9bcfed244dc6f6adf90f1ff127# 容器启动后多出 veth8ffe1a9 网卡[root@localhost ~]# ifconfig
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0inet6 fe80::42:59ff:feda:d58c prefixlen 64 scopeid 0x20<link>ether 02:42:59:da:d5:8c txqueuelen 0 (Ethernet)RX packets 6 bytes 432 (432.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 6 bytes 516 (516.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.0.151 netmask 255.255.255.0 broadcast 10.0.0.255inet6 fe80::773:49d0:5ac7:b300 prefixlen 64 scopeid 0x20<link>ether 00:0c:29:85:4e:cc txqueuelen 1000 (Ethernet)RX packets 1217 bytes 159012 (155.2 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 757 bytes 92813 (90.6 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0veth8ffe1a9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet6 fe80::eca7:5dff:fea7:5882 prefixlen 64 scopeid 0x20<link>ether ee:a7:5d:a7:58:82 txqueuelen 0 (Ethernet)RX packets 6 bytes 516 (516.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 12 bytes 1032 (1.0 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0# 查看docker 0 网桥,多出 veth8ffe1a9 网卡
[root@localhost ~]# brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.024259dad58c no veth8ffe1a9# 容器中存在 eth0 网卡
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
31f922e8b93d centos7-ssh "/bin/sh -c /usr/s..." About a minute ago Up About a minute 22/tcp, 80/tcp jolly_hamilton
[root@localhost ~]# docker exec -it 31f922e8b93d /bin/bash
[root@31f922e8b93d ansible]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 172.17.0.2 netmask 255.255.0.0 broadcast 0.0.0.0inet6 fe80::42:acff:fe11:1 prefixlen 64 scopeid 0x20<link>ether 02:42:ac:11:00:01 txqueuelen 0 (Ethernet)RX packets 16 bytes 1312 (1.2 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 8 bytes 656 (656.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0# 容器网关是 docker0
[root@31f922e8b93d ansible]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.17.0.1 0.0.0.0 UG 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
容器上网先发送到网关docker0,docker0与物理网卡桥接,最终通过物理网卡实现上网。如下:
[root@31f922e8b93d ansible]# traceroute www.baidu.com
traceroute to www.baidu.com (36.152.44.96), 30 hops max, 60 byte packets1 gateway (172.17.0.1) 0.066 ms 0.037 ms 0.080 ms2 10.0.0.2 (10.0.0.2) 0.354 ms 0.234 ms 0.304 ms
# 如何修改 docker0 IP
# docker-ce 版本修改/usr/lib/systemd/system/docker.service,ExecStart 后面加上 -b-br0
[root@localhost ~]# vim /etc/sysconfig/docker-network DOCKER_NETWORK_OPTIONS="--bip=172.17.3.3/16"[root@localhost ~]# systemctl restart docker
[root@localhost ~]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500inet 172.17.3.3 netmask 255.255.0.0 broadcast 0.0.0.0ether 02:42:59:da:d5:8c txqueuelen 0 (Ethernet)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.0.151 netmask 255.255.255.0 broadcast 10.0.0.255inet6 fe80::773:49d0:5ac7:b300 prefixlen 64 scopeid 0x20<link>ether 00:0c:29:85:4e:cc txqueuelen 1000 (Ethernet)RX packets 546 bytes 70483 (68.8 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 358 bytes 47206 (46.0 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
自定义桥接网卡br0,让容器直接桥接物理网卡
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-ens33 /tmp/
[root@localhost network-scripts]# vim ifcfg-ens33# 添加
BRIDGE=“br0"[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-br0
[root@localhost network-scripts]# vim ifcfg-br0 TYPE="Bridge"
BOOTPROTO=static
DEVICE=br0
ONBOOT=yes
IPADDR=10.0.0.149# 停止并删除docker0
[root@localhost network-scripts]# ifconfig docker0 down
[root@localhost network-scripts]# brctl delbr docker0
[root@localhost network-scripts]# systemctl restart network
[root@localhost network-scripts]# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.0.149 netmask 255.0.0.0 broadcast 10.255.255.255inet6 fe80::204e:beff:fe1b:8a9a prefixlen 64 scopeid 0x20<link>ether 00:0c:29:85:4e:cc txqueuelen 1000 (Ethernet)RX packets 518 bytes 43265 (42.2 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 309 bytes 41358 (40.3 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500ether 00:0c:29:85:4e:cc txqueuelen 1000 (Ethernet)RX packets 1130 bytes 110243 (107.6 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 756 bytes 114731 (112.0 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 4 bytes 332 (332.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 4 bytes 332 (332.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0vethb0d08fd: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet6 fe80::1086:3cff:fed9:3bfd prefixlen 64 scopeid 0x20<link>ether 12:86:3c:d9:3b:fd txqueuelen 0 (Ethernet)RX packets 8 bytes 656 (656.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 16 bytes 1312 (1.2 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@localhost network-scripts]# vim /etc/sysconfig/docker-network DOCKER_NETWORK_OPTIONS="-b=br0"[root@localhost network-scripts]# systemctl restart docker
[root@localhost network-scripts]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos7-ssh latest 45ef6218ff65 4 days ago 672 MB
nginx latest 5a3221f0137b 7 months ago 126 MB
docker.io/ansible/centos7-ansible latest 688353a31fde 3 years ago 447 MB
[root@localhost network-scripts]# docker run -itd centos7-ssh
cd3c9b1e5bc5fc14e7dc651488d5d035abf3627782ecbe1dd202fb02a87c3936
[root@localhost network-scripts]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cd3c9b1e5bc5 centos7-ssh "/bin/sh -c /usr/s..." 2 minutes ago Up 2 minutes 22/tcp, 80/tcp elated_shaw
[root@localhost network-scripts]# docker exec -it cd3c9b1e5bc5 /bin/bash
# 容器网关为物理网卡IP
[root@cd3c9b1e5bc5 ansible]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.149 0.0.0.0 UG 0 0 0 eth0
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 eth0
# 容器分配到与物理网卡相同网段的空闲IP
[root@cd3c9b1e5bc5 ansible]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500inet 10.0.0.1 netmask 255.0.0.0 broadcast 0.0.0.0inet6 fe80::42:aff:fe00:1 prefixlen 64 scopeid 0x20<link>ether 02:42:0a:00:00:01 txqueuelen 0 (Ethernet)RX packets 93 bytes 9501 (9.2 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 8 bytes 656 (656.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536inet 127.0.0.1 netmask 255.0.0.0inet6 ::1 prefixlen 128 scopeid 0x10<host>loop txqueuelen 1000 (Local Loopback)RX packets 0 bytes 0 (0.0 B)RX errors 0 dropped 0 overruns 0 frame 0TX packets 0 bytes 0 (0.0 B)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
四十四、Docker-网络模式相关推荐
- docker学习笔记(四):docker网络模式及桥接配置
2019独角兽企业重金招聘Python工程师标准>>> 1.docker网络模式:有如下五种: host模式(--net=host) container模式 ...
- Docker网络模式与数据管理
Docker网络模式与数据管理 前言 一.四种网络模式 (1)Host模式 (2)Container模式 (3)Bridge模式(默认) (4)None模式 (5)overlay2 二.自定义网络 ( ...
- Docker网络模式解析
目录 前言 一.常用基本命令 (一)查看网络 (二)创建网络 (三)查看网络源数据 (四)删除网络 二.网络模式 (一)总体介绍 (二)容器实例内默认网络IP生产规则 (三)案例说明 1.bridge ...
- 【k8s】docker网络模式(必知)
docker网络部分的视频我看了很多,讲解最透彻的还是https://www.bilibili.com/video/BV123411y7TB?p=8 获取本文方式:见谷粒商城文尾,备注[docker网 ...
- docker网络模式
目录 一.四种网络模式 1.1 Host模式 1.2 Container模式 1.3 Bridge模式(默认) 1.4 None模式(躺平) 二.自定义网络 2.1 查看网络模式列表 2.2 查看容器 ...
- 七、Docker网络模式详解
目录 一.docker网络概述 1.docker网络实现的原理 2.容器的端口映射 1).端口映射 2).四种端口映射 3).端口映射演示 (1).随机端口映射(-P) (2).指定端口映射(-p 宿 ...
- 【云原生 | Docker 高级篇】06、Docker 网络模式详解
目录 一.Docker 平台架构图解 整体说明: 二.Docker 网络是什么 三.Docker 网络常用基本命令 1.查看网络 2.查看网络源数据 3.删除网络 4.案例 四.Docker 能干 ...
- [系统安全] 四十四.APT系列(9)Metasploit技术之基础用法万字详解及防御机理
您可能之前看到过我写的类似文章,为什么还要重复撰写呢?只是想更好地帮助初学者了解病毒逆向分析和系统安全,更加成体系且不破坏之前的系列.因此,我重新开设了这个专栏,准备系统整理和深入学习系统安全.逆向分 ...
- 【Visual C++】游戏开发笔记四十四 浅墨DirectX教程十二 网格模型和X文件使用面面观
本系列文章由zhmxy555(毛星云)编写,转载请注明出处. 文章链接: http://blog.csdn.net/zhmxy555/article/details/8586540 作者:毛星云(浅墨 ...
- 1977-2021 高考四十四年,哪一张照片是属于你的记忆(珍贵!)
1977-2019 四十四年高考 一个国家命运的拐点 千百万个人生的转折 1977 四十四年 四十四图 1977年12月10日的高考, 是中国历史上唯一的一次冬季高考. 这一天,570多万从农 ...
最新文章
- php integer
- Codeforces Round #446 (Div. 1) B. Gluttony 构造 + 补集思想
- Java 10 正式发布!时隔 6 月带来 109 项新特性
- JavaScript语言概况(一)
- LeetCode:每日一题——数位成本和为目标值的最大数字
- 使用ExMerge工具管理Exchange用户邮箱。
- linux 动态链接库 函数共享,LINUX动态链接库高级应用(etc/ld.so.conf)共享动态链接库...
- zTree中设置idKey跟pId对象关联
- MySQL全文索引和like
- RFID射频识别的解读及应用
- Loongson2f_灵珑9S2A_debian5(lenny)更改国内archive软件源并使用源码编译安装bochs-2.6.9
- 谷歌身份验证器 手表_6条使您的三星手表更加Google-y的提示
- 最漂亮HTML5高端个人简历自适应模板
- PG内核分析 Question and Answer
- uint8_t / uint16_t / uint32_t /uint64_t 数据类型集中网上的解释
- 手把手微信机器人部署教学
- 重温数学基础——矩阵求逆
- 中国人工晶状体行业运行态势分析及发展战略规划建议报告2022-2028年版
- xilinx用户手册
- 图解jdk1.8中的intern()方法,包教包会