docker compose restart/stop should have an option to affect service's container only (original) (raw)

Description

Disclaimer: I think the major change in behavior might be intentionally done but in that case, there should be an option to use docker-compose v1's behavior.

In docker-compose v1, when you use docker-compose restart <service name>, only the service's container(s) is restarted. Other containers that are created by docker-compose run are not affected.

In docker compose v2, when you use docker compose restart <service name>, all containers that are related to the service are restarted. There might be many containers that were created by docker compose run <service> [command] that shouldn't be restarted or stopped with the service's container. I don't see any option in the command help that could do that.

Output of docker compose version:

Docker Compose version v2.1.1