This is the third part of the series Container Networking. I will explain a little bit about the docker container networking in this blog post.
\ I followed the steps mentioned in this to install docker on Ubuntu.
\ Post docker install, you can see the docker0 device in the list
ip link 1: lo:\ Let’s create a busybox container.
docker run --name bb -dt busybox\
docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 02429964e449 busybox "sh" About a minute ago Up About a minute bb\ In the device list, you see the veth7b01920@if16 interface is created with the master as docker0.
ip link 1: lo:\ Let’s check the network namespace.
ip netns list\ And you won’t see any network namespaces…How come??? This is because:
ip netns list command looks up network namespaces file in the /var/run/netns directory. However, the Docker daemon doesn’t create a reference of the network namespace file in the /var/run/netns directory after the creation. Therefore, ip netns ls cannot resolve the network namespace file Ref: https://www.baeldung.com/linux/docker-network-namespace-invisible\ If you want ip netns list to show the namespace name docker has created, then follow the below steps
export container_name=bb container_pid=$(sudo docker inspect -f '' $container_name) echo $container_pid sudo touch /var/run/netns/$container_name sudo mount -o bind /proc/$container_pid/ns/net /var/run/netns/$container_name\ Now, you can see the namespace name.
ip netns list bb (id: 0)\
sudo ip netns exec bb ip link 1: lo:\ The following diagram will help you visualize it better.
With this, I’m signing off. I hope this blog series helps to de-clutter your container networking.
All Rights Reserved. Copyright , Central Coast Communications, Inc.