WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Docker · Advanced · question 42 of 100

Can you explain the concept of a Docker overlay network, and how it enables container communication across multiple hosts?

📕 Buy this interview preparation book: 100 Docker questions & answers — PDF + EPUB for $5

A Docker overlay network is a type of network that enables communication between containers running on different hosts in a Docker swarm. It allows containers to communicate with each other as if they were on the same physical or virtual network, even if they are running on different hosts.

Overlay networks use a distributed control plane to manage network resources across multiple hosts. Each host in the swarm runs a local agent that communicates with other agents to maintain a consistent view of the network topology. When a container is started on a host, it is automatically attached to the overlay network, and its IP address is assigned by the distributed control plane.

Here are some key features and benefits of Docker overlay networks:

Multi-host communication: Overlay networks enable containers to communicate across multiple hosts in a Docker swarm, which allows for better scaling and load balancing of containerized applications.

Encrypted traffic: Overlay networks use encryption to secure communication between containers, which helps protect sensitive data and prevent unauthorized access.

Dynamic topology: Overlay networks can adapt to changes in the swarm topology, such as adding or removing hosts or containers, without requiring manual configuration.

Service discovery: Overlay networks can be used with Docker’s built-in service discovery mechanisms to automatically discover and connect to other services in the swarm.

Here is an example of how to create and use an overlay network in Docker:

Create an overlay network:

    docker network create --driver overlay my-network

Start a container on the overlay network: perl Copy code docker run –network=my-network my-image

Use the container’s hostname to communicate with other containers on the overlay network:

    curl http://my-container-1:8080

In this example, we create an overlay network called my-network using the docker network create command. We then start a container using the –network option to attach it to the overlay network. Finally, we use the container’s hostname (my-container-1) to communicate with another container on the network.

By using overlay networks, Docker enables container communication across multiple hosts in a swarm, which can help improve the scalability, resilience, and flexibility of containerized applications.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Docker interview — then scores it.
📞 Practice Docker — free 15 min
📕 Buy this interview preparation book: 100 Docker questions & answers — PDF + EPUB for $5

All 100 Docker questions · All topics