Docker 101 : Networking - Bridge network, user-defined network, ... -

Docker comes with different network drivers that would fit most applications.

But if there is a need for a more "customized" network driver, there are third party options, like weave for example.

We can create a weave network named "weave_1" using the below command:

Then we could attach the "nginx_container" container to the "weave_1" network using the below command:

The network drivers that come with docker are as follows:

  • Bridge: it is the default networking option for docker, it creates a virtual switch that connects the containers together.
  • Host: the container uses the same network stack as the host it "lives" on, we don't need to expose the container's host to be accessible from outside.
  • Overlay: it used to allow containers on different nodes to communicate. It uses the existing network structure and "overlays" another virtual network on top of that existing structure - vxlan for example -
  • Macvlan: it allows us to give the container a MAC address, so that the containers could use the network without going through the docker networking infrastructure.
  • None: using this network driver, the container has no network connection to the outside.
After setting up docker on a machine, it creates a docker bridge - docker0 -

We could list the virtual bridges on a system using the below command:


Containers names as opposed to containers IP addresses don't change if a container restarts for example, so applications could use names without worrying about the containers changing IP addresses.

To see the networks that exist on a docker host, we can use the following command:

To be able to have more information about each one of the above networks, we could use the below command:

If we decide to create a user-defined network, we could define different parameters for our network like the subnet of our network, its IP range, and its gateway


This network is internal to our host.

We could check if it was created as follows:


The gateway IP address is attached to the host interface.

To connect a container named "nginx_containerto the "network_1" network so it can communicate with the other containers that are on the same network, we use the following:

We could connect our container to the another network, network_2 network for example using the below command:

Then we disconnect from "network_1" network using the following:


Leave as a comment: