0
0
Dockerdevops~30 mins

Overlay networks in Swarm in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Overlay networks in Swarm
📖 Scenario: You are setting up a Docker Swarm cluster to run multiple services that need to communicate securely across different nodes. To enable this, you will create an overlay network that spans all nodes in the swarm.
🎯 Goal: Learn how to create an overlay network in Docker Swarm and attach services to it for cross-node communication.
📋 What You'll Learn
Create a Docker overlay network named my_overlay
Create a service named web attached to my_overlay
Create a service named db attached to my_overlay
Verify the services are running and connected to the overlay network
💡 Why This Matters
🌍 Real World
Overlay networks in Docker Swarm let multiple containers communicate securely across different physical or virtual machines, useful for scalable microservices.
💼 Career
Understanding overlay networks is essential for DevOps roles managing container orchestration and multi-host networking in production environments.
Progress0 / 4 steps
1
Initialize Docker Swarm
Run the command docker swarm init to initialize the current node as a swarm manager.
Docker
Need a hint?

Use docker swarm init to start the swarm on your current machine.

2
Create an overlay network
Create an overlay network named my_overlay using the command docker network create --driver overlay my_overlay.
Docker
Need a hint?

Use docker network create --driver overlay my_overlay to create the overlay network.

3
Deploy services attached to the overlay network
Create two services: web running the nginx image and db running the redis image. Attach both services to the my_overlay network using --network my_overlay.
Docker
Need a hint?

Use docker service create --name web --network my_overlay nginx and similarly for the db service.

4
Verify services and network connectivity
Run docker service ls to list the running services and docker network inspect my_overlay to check that the services are connected to the overlay network.
Docker
Need a hint?

Use docker service ls and docker network inspect my_overlay to verify.