1、Docker访问宿主机网络
在宿主机使用 ifconfig
查看
其中虚拟网卡 docker0 的 inet 地址 172.17.0.1
就是容器中访问宿主机的IP地址
[root@localhost hyperf]# ifconfig
docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:d7ff:fed1:8540 prefixlen 64 scopeid 0x20<link>
ether 02:42:d7:d1:85:40 txqueuelen 0 (Ethernet)
RX packets 18026 bytes 1113666 (1.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 29443 bytes 41263137 (39.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.120 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::50a5:60d4:9f7e:1ec9 prefixlen 64 scopeid 0x20<link>
ether 60:45:cb:80:5f:0c txqueuelen 1000 (Ethernet)
RX packets 3780856 bytes 1145120347 (1.0 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2270994 bytes 1287373084 (1.1 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 31426 bytes 23262635 (22.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 31426 bytes 23262635 (22.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vethd889dab: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::a431:5fff:fe37:32ba prefixlen 64 scopeid 0x20<link>
ether a6:31:5f:37:32:ba txqueuelen 0 (Ethernet)
RX packets 16295 bytes 1257140 (1.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 27284 bytes 37885941 (36.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
网友评论