peterlits zo
Posted on March 10, 2022
Docker has a lot of networks! There are some networks:
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?
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>
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!
But if you are not sure that you really need it, please do not use it in production environment.
$ docker run --net=host <image>
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.
(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>
Overlay
At the end
Thank you Krita! I enjoy draw picture with open source application!
Posted on March 10, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 25, 2024
November 28, 2024
November 14, 2024