Local network

Local network#

It’s very interesting that you can access the containers you’ve created from other devices on your local network. It may not be associated with Docker exactly, but with networks in general, but still I am only familiar with the Throw Docker feature.

So we start a container with nginx on port 80 on host.

docker run --rm -itd --name test_nginx -p 80:80 nginx
1f1ed27873110d1110ce588d1555c37f58bc7b5f7a8149f3e52423c0ed7e45db

Using the ifconfig Linux utility, I can check some information about the network. The most interesting part is the section starting with w. In the line inet <ip> you can find your ip address in the wifi network.

Note in your run ip can be different.

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:beff:fe7c:9302  prefixlen 64  scopeid 0x20<link>
        ether 02:42:be:7c:93:02  txqueuelen 0  (Ethernet)
        RX packets 4238  bytes 246696 (246.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6424  bytes 38000465 (38.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eno1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 88:ae:dd:0b:ae:af  txqueuelen 1000  (Ethernet)
        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
        device interrupt 16  memory 0xd6300000-d6320000  

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 7688  bytes 1587196 (1.5 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7688  bytes 1587196 (1.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vetheee0b29: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::cdd:11ff:feef:86d7  prefixlen 64  scopeid 0x20<link>
        ether 0e:dd:11:ef:86:d7  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 25  bytes 3124 (3.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp0s20f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.19  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::372e:c014:efa:1435  prefixlen 64  scopeid 0x20<link>
        ether c4:75:ab:c0:9b:df  txqueuelen 1000  (Ethernet)
        RX packets 397644  bytes 535358391 (535.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 79141  bytes 23420548 (23.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

You can connect any other device to this network and you’ll find that when you enter a higher ip you’ll get a nginx “welcome” page.

local_network

docker stop test_nginx &> /dev/null