2022-09-12 13:55:23 +01:00
|
|
|
# docker compose
|
2017-08-31 09:55:23 +01:00
|
|
|
|
2024-03-14 05:01:06 +00:00
|
|
|
> Run and manage multi container Docker applications.
|
2021-10-13 18:23:45 +01:00
|
|
|
> More information: <https://docs.docker.com/compose/reference/>.
|
2017-08-31 09:55:23 +01:00
|
|
|
|
2019-10-30 12:59:17 +00:00
|
|
|
- List all running containers:
|
|
|
|
|
2022-09-12 13:55:23 +01:00
|
|
|
`docker compose ps`
|
2019-10-30 12:59:17 +00:00
|
|
|
|
2017-08-31 09:55:23 +01:00
|
|
|
- Create and start all containers in the background using a `docker-compose.yml` file from the current directory:
|
|
|
|
|
2023-02-08 15:31:15 +00:00
|
|
|
`docker compose up --detach`
|
2017-08-31 09:55:23 +01:00
|
|
|
|
|
|
|
- Start all containers, rebuild if necessary:
|
|
|
|
|
2022-09-12 13:55:23 +01:00
|
|
|
`docker compose up --build`
|
2017-08-31 09:55:23 +01:00
|
|
|
|
2023-08-20 16:13:48 +01:00
|
|
|
- Start all containers by specifying a project name and using an alternate compose file:
|
2017-08-31 09:55:23 +01:00
|
|
|
|
2023-08-20 16:13:48 +01:00
|
|
|
`docker compose -p {{project_name}} --file {{path/to/file}} up`
|
2017-08-31 09:55:23 +01:00
|
|
|
|
|
|
|
- Stop all running containers:
|
|
|
|
|
2022-09-12 13:55:23 +01:00
|
|
|
`docker compose stop`
|
2017-08-31 09:55:23 +01:00
|
|
|
|
|
|
|
- Stop and remove all containers, networks, images, and volumes:
|
|
|
|
|
2022-09-12 13:55:23 +01:00
|
|
|
`docker compose down --rmi all --volumes`
|
2017-08-31 09:55:23 +01:00
|
|
|
|
|
|
|
- Follow logs for all containers:
|
|
|
|
|
2022-09-12 13:55:23 +01:00
|
|
|
`docker compose logs --follow`
|
2020-10-24 13:59:15 +01:00
|
|
|
|
|
|
|
- Follow logs for a specific container:
|
|
|
|
|
2022-09-12 13:55:23 +01:00
|
|
|
`docker compose logs --follow {{container_name}}`
|