Thursday 9 June 2022

Troubleshooting Container Networking


sudo docker run -t -d --name container1 ubuntu:latest

Unable to find image 'ubuntu:latest' locally

latest: Pulling from library/ubuntu

405f018f9d1d: Pull complete 

Digest: sha256:b6b83d3c331794420340093eb706a6f152d9c1fa51b262d9bf34594887c2c7ac

Status: Downloaded newer image for ubuntu:latest

4028436d8746c32740ff9224958071d0d85c4303fd6c649fd4cbbf431cccf60f


 sudo docker ps

CONTAINER ID        IMAGE                  COMMAND                  CREATED              STATUS              PORTS                    NAMES

4028436d8746        ubuntu:latest          "bash"                   About a minute ago   Up About a minute                            container1


sudo docker inspect container1

[

    {

        "Id": "4028436d8746c32740ff9224958071d0d85c4303fd6c649fd4cbbf431cccf60f",

        "Created": "2022-06-09T19:48:58.584614038Z",

        "Path": "bash",

<...>


 sudo docker inspect container1 | grep Networks -A15

            "Networks": {

                "bridge": {

                    "IPAMConfig": null,

                    "Links": null,

                    "Aliases": null,

                    "NetworkID": "f22c094fc7798f6d435ea090ad0a29793e926b29b67632c58ee8700c55863d01",

                    "EndpointID": "ce87b34dc51f4df558d00da748f2aab74a41136f240274048ab0ff263ca23fe1",

                    "Gateway": "172.17.0.1",

                    "IPAddress": "172.17.0.3",

                    "IPPrefixLen": 16,

                    "IPv6Gateway": "",

                    "GlobalIPv6Address": "",

                    "GlobalIPv6PrefixLen": 0,

                    "MacAddress": "02:42:ac:11:00:03",

                    "DriverOpts": null

                }


sudo docker container logs <container id/ name>

sudo docker network inspect -v <network id/name>

sudo docker node ls


#Troubleshooting using network tools like nicolaka or netshoot


sudo docker run -it --net container:container1 nicolaka/netshoot

                    dP            dP                           dP   

                    88            88                           88   

88d888b. .d8888b. d8888P .d8888b. 88d888b. .d8888b. .d8888b. d8888P 

88'  `88 88ooood8   88   Y8ooooo. 88'  `88 88'  `88 88'  `88   88   

88    88 88.  ...   88         88 88    88 88.  .88 88.  .88   88   

dP    dP `88888P'   dP   `88888P' dP    dP `88888P' `88888P'   dP   

                                                                    

Welcome to Netshoot! (github.com/nicolaka/netshoot)

                                                                

 4028436d8746  ~  ifconfig

eth0      Link encap:Ethernet  HWaddr 02:42:AC:11:00:03  

          inet addr:172.17.0.3  Bcast:172.17.255.255  Mask:255.255.0.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:29 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:3389 (3.3 KiB)  TX bytes:0 (0.0 B)


lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:65536  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


 4028436d8746  ~  ip route show

default via 172.17.0.1 dev eth0 

172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.3 


 4028436d8746  ~  exit


#following commands can be used inside network namespace 

ifconfig #interface list

brctl show #bridge list

ip route show #route table

bridge fdb show #encapsulation detail

ipvsadm #load balancing


No comments:

Post a Comment