0
0
Dockerdevops~30 mins

Network isolation between services in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Network isolation between services
📖 Scenario: You are setting up two simple services using Docker containers. You want to make sure these services cannot talk to each other by isolating their networks.This is like having two separate rooms in a house where people cannot hear or see each other.
🎯 Goal: Create two Docker containers each connected to its own isolated network. Verify that the containers cannot communicate with each other.
📋 What You'll Learn
Create two Docker networks named network1 and network2
Run two containers named service1 and service2 each connected to one of the networks
Try to ping service2 from service1 and confirm it fails
Print the ping command output to show network isolation
💡 Why This Matters
🌍 Real World
Network isolation is used to keep different services or applications separated for security and stability, like having separate rooms for different activities.
💼 Career
Understanding Docker network isolation is important for DevOps roles to manage containerized applications securely and avoid unwanted communication between services.
Progress0 / 4 steps
1
Create two Docker networks
Create two Docker networks named network1 and network2 using the docker network create command.
Docker
Need a hint?

Use docker network create followed by the network name.

2
Run two containers on separate networks
Run two containers named service1 and service2 using the alpine image. Connect service1 to network1 and service2 to network2. Use the docker run command with --network and --name options.
Docker
Need a hint?

Use docker run -dit --name <name> --network <network> alpine sh to start containers.

3
Try to ping service2 from service1
Use docker exec to run the command ping -c 1 service2 inside the service1 container. This tests if service1 can reach service2.
Docker
Need a hint?

Use docker exec service1 ping -c 1 service2 to test connectivity.

4
Show the ping output to confirm isolation
Print the output of the ping command run inside service1 to show that service2 is unreachable due to network isolation.
Docker
Need a hint?

The ping command should fail because the networks are isolated.