DEV Community

Cover image for Docker Network
peterlits zo
peterlits zo

Posted on • Edited on

Docker Network

Docker has a lot of networks! There are some networks:

Image description

I will try to list them and try my best to explain them.

None

Well! This is easy, none means none! None network for docker container, right?

Image description

Although that we can use network in host, we cannot use network in docker container.

But we can use docker daemon to talk with container when we are in host.

$ docker run --net=none <image>
Enter fullscreen mode Exit fullscreen mode

Host

The second network is host. It will just use the host's network. Sometime it will be danger but it is really easy to use and it has better network I/O speed!

Image description

But if you are not sure that you really need it, please do not use it in production environment.

$ docker run --net=host <image>
Enter fullscreen mode Exit fullscreen mode

Bridge

Bridge is usually a hardware that works on the Link Layer. It is used to make two or more networks into just one.

And it is also the default network mode.

Image description

(The card in the host machine is the network card)

But in docker, we can have a bridge works in Linux kernel. Well it is cool.

At first, docker will create a virtual bridge, named docker0. If you use the command ip a in shell, you will find the bridge docker0 created by docker.

And bridge mode is default mode.

To use the network, the container will have an mocked Ethernet network card. It's name is eth0, which is linked to docker0 bridge to communicate with host and the great Internet!

$ docker run <image>
Enter fullscreen mode Exit fullscreen mode

Overlay

At the end

Thank you Krita! I enjoy draw picture with open source application!

Top comments (1)

Collapse
 
peterlitszo profile image
peterlits zo

Wait for me >_<!