correct compose down example with profile (#22278)

The down command used with profile will stop the services with a given
profile but also all the services without any profiles

## Description
Correct the section of stopping services with a specific profile in the
how-to profile documentation page

## Related issues or tickets
https://github.com/docker/compose/issues/12648
## Reviews

<!-- Notes for reviewers here -->
<!-- List applicable reviews (optionally @tag reviewers) -->

- [ ] Technical review
- [x] Editorial review
- [ ] Product review

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours
2025-03-19 12:10:09 +01:00
committed by GitHub
parent 8dbdd7f9ec
commit f54284dfb1
2 changed files with 12 additions and 3 deletions

View File

@@ -1 +1 @@
Profiles help you adjust your Compose application for different environments or use cases by selectively activating services. Services can be assigned to one or more profiles; unassigned services start by default, while assigned ones only start when their profile is active. This setup means specific services, like those for debugging or development, to be included in a single `compose.yml` file and activated only as needed.
Profiles help you adjust your Compose application for different environments or use cases by selectively activating services. Services can be assigned to one or more profiles; unassigned services start/stop by default, while assigned ones only start/stop when their profile is active. This setup means specific services, like those for debugging or development, to be included in a single `compose.yml` file and activated only as needed.

View File

@@ -175,7 +175,7 @@ $ docker compose --profile dev up phpmyadmin
$ COMPOSE_PROFILES=dev docker compose up phpmyadmin
```
## Stop specific profiles
## Stop application and services with specific profiles
As with starting specific profiles, you can use the `--profile` [command-line option](/reference/cli/docker/compose.md#use--p-to-specify-a-project-name) or
use the [`COMPOSE_PROFILES` environment variable](environment-variables/envvars.md#compose_profiles):
@@ -187,7 +187,7 @@ $ docker compose --profile debug down
$ COMPOSE_PROFILES=debug docker compose down
```
Both commands stop and remove services with the `debug` profile. In the following `compose.yaml` file, this stops the services `db` and `phpmyadmin`.
Both commands stop and remove services with the `debug` profile and services without a profile. In the following `compose.yaml` file, this stops the services `db`, `backend` and `phpmyadmin`.
```yaml
services:
@@ -207,6 +207,15 @@ services:
image: mysql
```
if you only want to stop the `phpmyadmin` service, you can run
```console
$ docker compose down phpmyadmin
```
or
```console
$ docker compose stop phpmyadmin
```
> [!NOTE]
>
> Running `docker compose down` only stops `backend` and `db`.