1
0
mirror of https://github.com/docker/docs.git synced 2026-10-25 06:09:46 +03:00
Files
docs/content/guides/docker-compose.md
Brandon Hunt 97cee42f3c docs: collapse folder+index.md guides to flat single-file guides (#25504)
## Description

Follow-up to #25338 (the guides revamp). That PR collapsed most
multi-page guide series into single pages but left ~50 guides wrapped in
a `<name>/index.md` directory structure alongside guides that are
already flat `<name>.md` files — an inconsistent mix. This PR finishes
the flattening:

- Flattens 50 folder-wrapped guides to `content/guides/<slug>.md` via
`git mv` (history preserved). These keep the same URL, since Hugo
generates the same permalink for a leaf-bundle `dir/index.md` and a flat
`dir.md`.
- Moves the last 4 guides' local per-guide image bundles
(`genai-leveraging-rag`, `genai-video-bot`, `genai-claude-code-mcp`,
`java`) into the shared `content/guides/images/` folder with
slug-prefixed filenames, matching the convention already used by most
other guides (`databases-1.webp`, `kafka-1.webp`, etc.), and rewrites
the in-body image references.
- Normalizes `genai-claude-code-mcp`'s non-standard filename
(`claude-code-mcp-guide.md`) and capitalized `Images/` folder to match
convention.
- Promotes `content/guides/frameworks/laravel/index.md` to a top-level
`content/guides/laravel.md`, since it was the only guide under
`frameworks/` and every other language/framework guide is flat.
- Adds `aliases` entries for the two URLs that actually changed
(`/guides/frameworks/laravel/` and
`/guides/genai-claude-code-mcp/claude-code-mcp-guide/`); every other
rename preserves its existing URL.

Companion PR establishing this as the documented convention going
forward: #25503

## Validation

- `hugo --minify` build via `docker compose run` completes with zero
warnings/errors (3174 pages, 1524 aliases — unchanged from before this
PR).
- Verified both changed-URL guides render at their new path and the old
path 301s via the Hugo alias redirect.
- Verified every image reference in the 4 migrated guides resolves to an
existing file in `content/guides/images/`.
- Multi-agent docs review (link-checker, cross-reference-checker,
guide-conventions) found zero issues.

## Related issues or tickets

Discussed in the team's docs Slack channel following #25338.

## Reviews

- [ ] Technical review
2026-07-09 08:45:55 -07:00

6.6 KiB
Raw Permalink Blame History

title, linkTitle, summary, description, keywords, aliases, params
title linkTitle summary description keywords aliases params
Defining and running multi-container applications with Docker Compose Docker Compose Simplify the process of defining, configuring, and running multi-container Docker applications. Learn how to use Docker Compose to define and run multi-container Docker applications. docker compose, multi-container, compose file, services, orchestration, yaml
/learning-paths/docker-compose/
/guides/docker-compose/common-questions/
/guides/docker-compose/setup/
/guides/docker-compose/why/
tags image time
cicd
images/learning-paths/compose.png 10 minutes

Developers face challenges with multi-container Docker applications, including complex configuration, dependency management, and maintaining consistent environments. Networking, resource allocation, data persistence, logging, and monitoring add to the difficulty. Security concerns and troubleshooting issues further complicate the process, requiring effective tools and practices for efficient management.

Docker Compose solves the problem of managing multi-container Docker applications by providing a simple way to define, configure, and run all the containers needed for an application using a single YAML file. This approach helps developers to easily set up, share, and maintain consistent development, testing, and production environments, ensuring that complex applications can be deployed with all their dependencies and services properly configured and orchestrated.

What you’ll learn

  • What Docker Compose is and what it does
  • How to define services
  • Use cases for Docker Compose
  • How things would be different without Docker Compose

Who’s this for?

  • Developers and DevOps engineers who need to define, manage, and orchestrate multi-container Docker applications efficiently across multiple environments.
  • Development teams that want to increase productivity by streamlining development workflows and reducing setup time.

Tools integration

Works well with Docker CLI, CI/CD tools, and container orchestration tools.

Why Docker Compose?

Docker Compose is an essential tool for defining and running multi-container Docker applications. Docker Compose simplifies the Docker experience, making it easier for developers to create, manage, and deploy applications by using YAML files to configure application services.

Docker Compose provides several benefits:

  • Lets you define multi-container applications in a single YAML file.
  • Ensures consistent environments across development, testing, and production.
  • Manages the startup and linking of multiple containers effortlessly.
  • Streamlines development workflows and reduces setup time.
  • Ensures that each service runs in its own container, avoiding conflicts.

{{< youtube-embed 2EqarOM2V4U >}}

Demo: set up and use Docker Compose

This Docker Compose demo shows how to orchestrate a multi-container application environment, streamlining development and deployment processes.

  • Compare Docker Compose to the docker run command
  • Configure a multi-container web app using a Compose file
  • Run a multi-container web app using one command

{{< youtube-embed P5RBKmOLPH4 >}}

Common challenges and questions

Do I need to maintain a separate Compose file for my development, testing, and staging environments?

You don't necessarily need to maintain entirely separate Compose files for your development, testing, and staging environments. You can define all your services in a single Compose file (compose.yaml). You can use profiles to group service configurations specific to each environment (dev, test, staging).

When you need to spin up an environment, you can activate the corresponding profiles. For example, to set up the development environment:

$ docker compose --profile dev up

This command starts only the services associated with the dev profile, leaving the rest inactive.

For more information on using profiles, see Using profiles with Compose.

How can I enforce the database service to start up before the frontend service?

Docker Compose ensures services start in a specific order by using the depends_on property. This tells Compose to start the database service before even attempting to launch the frontend service. This is crucial since applications often rely on databases being ready for connections.

However, depends_on only guarantees the order, not that the database is fully initialized. For a more robust approach, especially if your application relies on a prepared database (e.g., after migrations), consider health checks. Here, you can configure the frontend to wait until the database passes its health check before starting. This ensures the database is not only up but also ready to handle requests.

For more information on setting the startup order of your services, see Control startup and shutdown order in Compose.

Can I use Compose to build a Docker image?

Yes, you can use Docker Compose to build Docker images. Docker Compose is a tool for defining and running multi-container applications. Even if your application isn't a multi-container application, Docker Compose can make it easier to run by defining all the docker run options in a file.

To use Compose, you need a compose.yaml file. In this file, you can specify the build context and Dockerfile for each service. When you run the command docker compose up --build, Docker Compose will build the images for each service and then start the containers.

For more information on building Docker images using Compose, see the Compose Build Specification.

What is the difference between Docker Compose and Dockerfile?

A Dockerfile provides instructions to build a container image while a Compose file defines your running containers. Quite often, a Compose file references a Dockerfile to build an image to use for a particular service.

What is the difference between the docker compose up and docker compose run commands?

The docker compose up command creates and starts all your services. It's perfect for launching your development environment or running the entire application. The docker compose run command focuses on individual services. It starts a specified service along with its dependencies, allowing you to run tests or perform one-off tasks within that container.