Docker Compose for Microservices with Scaling and Health Checks
Build a 4-service microservices stack with Docker Compose, scale replicas, add HEALTHCHECK and restart policies, and test failover and recovery.

Lab overview
A microservices architecture breaks a single application into many small, independent services that talk to each other over the network. This makes a system easier to scale and more resilient - each service can be run, updated, and recovered on its own - but it also raises new questions: how do services find each other, how do you know a service is truly ready to serve traffic (not just started), and how does the system recover when a container dies? Docker Compose answers all three for local and team-scale setups: a single docker-compose.yml describes the whole stack, Compose's built-in DNS lets services reach each other by name and load-balances across replicas, and health checks let the runtime tell "running" apart from "healthy."
Real-world stacks stay online because of three things: replicas, so the system survives a container dying; health checks, so the platform knows which replicas are ready; and restart policies, so failures heal themselves without waking anyone up. In this lab, you will work with a four-service stack — an Nginx API gateway, two backend services, and a RabbitMQ message queue — running inside a Docker IDE. You will bring the stack up and explore how it is wired, scale a backend to multiple replicas and watch Compose's DNS spread traffic across them, add health checks so Docker can report real readiness, apply a restart policy to the key services, and finally prove it all works by crashing a replica and watching the stack heal itself while still serving every request.
Objectives
Upon completion of this intermediate level lab, you will be able to:
- Understand how a multi-service
docker-compose.ymlconnects an API gateway, two backend services, and a RabbitMQ message queue over a shared bridge network. - Scale a backend service to multiple replicas with
docker compose up --scaleand verify DNS round-robin service discovery from inside the gateway container. - Add a
HEALTHCHECKdirective to a service Dockerfile and configure a Compose-levelhealthcheckblock on the RabbitMQ service. - Apply
restart: unless-stoppedto critical services and demonstrate self-healing by killing a replica and observing automatic recovery. - Inspect container health status, restart policies, and replica counts using
docker compose ps,docker inspect, and Compose CLI commands.
Who is this lab for?
This lab is designed for:
- Developers and platform engineers who have written basic Dockerfiles and run single containers, now wanting to compose multi-service applications.
- DevOps practitioners moving from single-container thinking to multi-service stacks with service discovery, health probes, and restart-driven self-healing.
Verified against your live environment
An automated validation engine inspects your actual resources and configurations as you work. Completion means the task was performed, not multiple choice, real-world proficiency.
More labs like this
Deploy Multi-Container Apps with Docker Compose
Author a compose.yaml that runs nginx, a Python API, and Postgres as a single declarative multi-service stack.
Externalize Docker Configuration with Environment Variables and Compose Secrets
Externalize Docker app config the 12-factor way using -e, --env-file, Compose env_file, and Compose secrets.
Running Containers with docker run and kubectl
Run nginx:alpine first with docker run then with kubectl run on the same VM, and see how Kubernetes maps onto Docker concepts.
Environment
Every lab includes
- Real environment, pre-credentialed
- Automated checks on every step
- Isolated sandbox, auto cleanup
- AI-recommended next steps
Lab curriculum
- 01
Getting Started with Docker IDE
- 02
Build the Microservices Compose File with Four Services
1 automated check
- 03
Add HEALTHCHECK Directive and Compose Healthcheck Config
1 automated check
- 04
Scale the Backend Service to Multiple Replicas
1 automated check
- 05
Configure Restart Policies and Service Dependencies
1 automated check
- 06
Test Failover by Killing a Replica
1 automated check
Not the lab you were looking for?
Browse 200+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.