Home > Net >  Host network do not have a IP segment who contains the docker host network model's interface IP
Host network do not have a IP segment who contains the docker host network model's interface IP

Time:10-16

I get the four model types of docker network snapshot:

enter image description here

the host model (Open container) is attached to host machine's Logical host interface and Loopback interface.

in my case, I created the host model container:

$ docker run --name container-bridge --network=host  -it --rm busybox:latest

and in the container it has 10 virtual interfaces.

/ # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 02:50:00:00:00:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.65.3/24 brd 192.168.65.255 scope global deprecated dynamic noprefixroute eth0
       valid_lft 1415sec preferred_lft 0sec
    inet6 fe80::50:ff:fe00:1/64 scope link 
       valid_lft forever preferred_lft forever
3: tunl0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
    link/ipip 0.0.0.0 brd 0.0.0.0
4: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop qlen 1000
    link/tunnel6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
5: services1@if6: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue 
    link/ether c2:db:47:39:c7:fc brd ff:ff:ff:ff:ff:ff
    inet 192.168.65.4 peer 192.168.65.5/32 scope global services1
       valid_lft forever preferred_lft forever
    inet6 fe80::c0db:47ff:fe39:c7fc/64 scope link 
       valid_lft forever preferred_lft forever
7: br-b7cc12043647: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue 
    link/ether 02:42:30:d7:06:a7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.49.1/24 brd 192.168.49.255 scope global br-b7cc12043647
       valid_lft forever preferred_lft forever
    inet6 fe80::42:30ff:fed7:6a7/64 scope link 
       valid_lft forever preferred_lft forever
8: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue 
    link/ether 02:42:9e:26:2d:f9 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:9eff:fe26:2df9/64 scope link 
       valid_lft forever preferred_lft forever
10: veth2fba778@if9: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue master br-b7cc12043647 
    link/ether 52:64:9d:7f:d1:01 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::5064:9dff:fe7f:d101/64 scope link 
       valid_lft forever preferred_lft forever

the main interface is eth0 for connecting to host(my macos), who has IP address of 192.168.65.3/24

but in my macos I do not find a IP address under the segment 192.168.65.0/24.

$ ifconfig -a | grep 192.168.65

CodePudding user response:

See Use host networking, it clealy mentioned the --net=host not works on macos:

The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

So, the network in container surely not same as the one in your macos.

  • Related