Introduction to Docker Networks

A brief introduction to Docker networks

In the fundamentals section, we discussed that we will add a database to the app in the coming section. We will add the database as a container and our app will connect to the database using the Docker network.

So, it is important to know a little bit about the Docker network so that you can troubleshoot any problem you face in future.

Network fundamentals

The network is nothing but an area that allows somebody to reach others with defined permissions and protocols.

We will not go deep into networking, but just small important commands and concepts regarding Docker.

Network terminologies and commands

There are some terminologies used in Networking. Some of them are:

  • Hostname: This is the most-frequently-used word. It’s the name of the machine to identify it in a network.

  • ping: ping <hostname>/<ip> command is used to check the connectivity of machine from the machine from which the command is run.

  • subnet: This is a small isolated part of a network. It is like creating boundaries to a particular part in the same network.

  • DNS: This is like a phone directory. All the reachable hosts are mapped in this domain name service/system using IP and hostname so that you can either reach them by name or IP.

  • /etc/hosts: This is the important file. This file has all the reachable hosts with their IP addresses. We will frequently refer to this file.

Docker communication

As you can see in the diagram, we have connected the container’s port 5000 to the host’s 5000 and as a result, we can access whatever is running on the 5000 port on the container.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy