Docker Networking - Docker (software)

What is Docker Networking?

Communication happens between containers unleashing the power of networking that Docker can provide. This communication can happen with Docker Host as well. We get to know the Docker Ethernet adapter using ifconfig on the Docker Host. We can find this adapter got created during the installation of Host.

ifconfig

It acts like an mediator or kind of bridge or link between Linux and Docker Host. We shall see some of its commands.

Listing All Docker Networks

Below is the command to display all the available networks.

Syntax

Options

None

Return Value

This shows all the available networks.

Example

Output

Below is the result for the above command -

docker_networks

Inspecting a Docker network

Using Docker network inspect command, we can drill more into the network information.

Syntax

Options

  • networkname – The network name that we wish to view details.

Return Value

Network details are displayed.

Example

Output

Below is the result for the above command −

inspecting_docker_network

Its time to look how the things go, we will run a container and check the network. Execute the below command on Ubuntu container –

run_a_container_in_network

Next is to find the name of the network and can be done using below command. We will know that bridge is attached to the container.

container_attached_to_bridge

Creating Your Own New Network

Before creating containers only we can create our own network and we will see how this can be done. Give the below command −

Syntax

Options

  • drivername – Name of the network driver.
  • name – It is the network name.

Return Value

We will get the network long ID.

Example

Output

Below is the result for the above command −

long_id

Now while launching container, we can attach a network. Take a look at the below command to make it happen –

new_network

Give the below command to inspect the network and find the network that is attached to the container.

new_nw

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Docker (software) Topics