Set a fixed container name in Docker Compose with container_name

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: myapp` to the service.
  2. The container is created with exactly that name instead of the auto-generated <project>-<service>-<n> name.
  3. Name must match the regex [a-zA-Z0-9][a-zA-Z0-9_.-]+.
  4. Start with `docker compose up -d` and the fixed name is used.
  5. Docs: https://docs.docker.com/compose/compose-file/05-services/

Known gotchas

Related routes

Give a Docker Compose service a fixed container_name and understand its single-instance limit
docs.docker.com/compose/compose-file/05-services · 5 steps · unrated
Create a named Docker volume and attach it to a container
docs.docker.com · 7 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