Search code examples
dockerdocker-compose

Docker Compose Down All Profiles


I have a Docker Compose file that uses multiple profiles.

I've noticed that I need to call the specific profiles when calling docker compose down and I'm curious if there's a way around this.

For example:

services:
  service1:
    ...
    profile:
      - profile1

  service2:
    ...

When I call docker compose --profile profile1 up it will bring up both service1 and service2 as expected.

However, when I call docker compose down it will only take down service2, i.e. the one with no associated profiles. I have to call docker compose --profile profile1 down to explicitly take down service.

Is there a way around this?


Solution

  • According to the documentation you can achieve that with an asterisk.

    docker compose --profile "*" down

    This will tear down all services even if they had an assigned profile.

    (Note that the --profile attribute must come before the down command)