dockerdocker-compose

Launching a docker compose service using a profile and then stopping it


I have the following services:

If I do the following:

docker compose --profile support up

It will launch ServiceA and ServiceB, and that's what I would expect it to do.

However, if I run:

docker compose stop

It just returns without any response.

If I run docker compose ps I can see that ServiceA and ServiceB are still running.

I have to explicitly state the profile like so:

docker compose --profile support stop

My question is two fold:

  1. Service A/B are part of the default profile, why do I have to specify a profile?
  2. There is no way I can tell what profile a service was started with, so why shouldn't docker compose stop simply stop all services that are running?

Is this a bug or a feature?


Solution

  • Service A/B are part of the default profile, why do I have to specify a profile?

    A profile named "default" is not a default profile. Default profile is like an unassigned profile.

    why shouldn't docker compose stop simply stop all services that are running?

    It will stop all services with unassigned profile. To stop default profile you can use docker compose --profile default stop.


    Actually I just tested that an empty string profile is equal to an unassigned profile, so you use that instead of a profile named default.

    ---
    services:
      test:
        image: busybox
        command: sleep infinity
        profiles: [frontend, '']