0
0
Dockerdevops~30 mins

Service scaling in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Service scaling with Docker Compose
📖 Scenario: You are managing a simple web application using Docker Compose. To handle more users, you want to run multiple copies of the web service.
🎯 Goal: Learn how to scale a Docker Compose service by increasing the number of running containers.
📋 What You'll Learn
Create a Docker Compose file with a web service
Add a scale variable to control the number of containers
Use the Docker Compose command to scale the service
Display the number of running containers after scaling
💡 Why This Matters
🌍 Real World
Scaling services with Docker Compose helps handle more users by running multiple copies of the same service.
💼 Career
Understanding service scaling is essential for DevOps roles to manage application availability and load.
Progress0 / 4 steps
1
Create a Docker Compose file with a web service
Create a file named docker-compose.yml with a service called web that uses the image nginx:latest.
Docker
Need a hint?

Use YAML syntax to define the service under services with the name web and specify the image nginx:latest.

2
Add a scale variable to control the number of containers
Create a variable called scale_count and set it to 3 to represent how many containers you want to run.
Docker
Need a hint?

Define a variable named scale_count and assign it the value 3.

3
Use the Docker Compose command to scale the service
Write a shell command string called scale_command that uses docker-compose up -d --scale web=3 to start 3 containers of the web service using the scale_count variable.
Docker
Need a hint?

Use an f-string to insert scale_count into the command string.

4
Display the number of running containers after scaling
Write a print statement that outputs exactly: Running 3 containers of web service using the scale_count variable.
Docker
Need a hint?

Use a print statement with an f-string to show the number of containers running.