# Docker-compose

Docker Compose is a tool that makes it easier to create and run multi-container applications.&#x20;

It automates the process of managing several Docker containers simultaneously, such as a website frontend, API, and database service.

Docker Compose allows you to define your application’s containers as code inside a YAML file you can commit to your source repository.&#x20;

Once you’ve created your file (normally named docker-compose.yml), you can start all your containers (called “services”) with a single Compose command.

<figure><img src="/files/3sFXGJ6XOwrZdVslhDD6" alt=""><figcaption><p>docker-compose</p></figcaption></figure>

Compared with manually starting and linking containers, Compose is quicker, easier, and more repeatable.

Compose automatically creates a Docker network for your project, ensuring your containers can communicate with each other.&#x20;

It also manages your Docker storage volumes, automatically reattaching them after a service is restarted or replaced.

### Why use docker compose?

Most real-world applications have several services with dependency relationships—for example, your app may run in one container, but depend on a database server that’s deployed adjacently in another container.&#x20;

Moreover, services usually need to be configured with storage volumes, environment variables, port bindings, and other settings before they can be deployed.

This improves developer ergonomics, supports reuse of the stack in multiple environments, and helps prevent accidental misconfiguration.

### Docker Compose Workflow

<figure><img src="/files/spFFfbMsOfk6yshyPY16" alt=""><figcaption><p>Docker Compose Workflow</p></figcaption></figure>

### Docker Vs Docker Compose

Docker is a containerization engine that provides a CLI for building, running, and managing individual containers on your host.

Compose is a tool that expands Docker with support for multi-container management. It supports “stacks” of containers that are declaratively defined in project-level config files.

### Docker Compose Benefits

* Fast and easy configuration with YAML scripts
* Single host deployment
* Increased productivity
* Security with isolated containers


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devops-3.gitbook.io/devops/docs/module-7-docker/docker-compose.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
