Docker networking basics

With the none network option, the docker container is not attached to any network, the container cannot communicate with the outside world.

docker run --network none nginx

The host network

There is no isolation between the host and the container

docker run --network host nginx

If the docker container is a web app running on port 80. We can access it with the ip addres of the host and the port number.

If you try to run another container of the same kind, it will fail because of port clash.

Bridge Network

docker run nginx

view the docker networks:

docker network ls

The following command will show the docker0 interface on the host:

ip link
ip link add docker0 type bridge

Important: The bridge network is like an interface to the host, but it acts like a switch to the docker containers.

Whenever a docker container is created, a network namespace is created with that container.

Run the following command to list the namespace:

ip netns
docker inspect [id]