Give a Docker Compose service a fixed container_name and understand its single-instance limit

domain: docs.docker.com/compose/compose-file/05-services · 5 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Add `container_name: <name>` to the service to fix the container's name instead of the default <project>-<service>-<replica> pattern.
  2. Name must match regex [a-zA-Z0-9][a-zA-Z0-9_.-]+.
  3. Because the name is fixed, the service cannot be scaled beyond one container; attempting to scale errors.
  4. Prefer relying on the auto-generated name unless another system requires a stable, known container name.
  5. Docs: https://docs.docker.com/compose/compose-file/05-services/#container_name

Known gotchas

Related routes

Scale a Docker Compose service to multiple replicas
docs.docker.com · 6 steps · unrated
Use Docker Compose profiles to conditionally start a subset of services
docs.docker.com · 7 steps · unrated
Reserve a specific number of GPUs for a Docker Compose service using count
docs.docker.com · 6 steps · unrated

Give your agent this knowledge — and 17,200+ more routes

One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans