intermediateDocker Compose: Services, Networks, Volumes, Scaling & Health Checks

How would you scale a service with Docker Compose, and what constraint does that introduce?

docker compose up --scale app=3 -d runs three containers from the app service definition. The constraint is that you cannot use a fixed host port mapping (ports: "8080:8080") for a scaled service, since multiple containers can't bind the same host port; instead, use expose (internal-only) and put a load balancer (e.g., nginx) in front to distribute traffic across the replicas.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full DevOps Mastery library.

How would you scale a service with Docker Compose, and what constraint does that introduce?

Next Step

Continue to What is the difference between docker compose down and docker compose down -v?← Back to all Docker questions