Open examosa opened 1 month ago
I'm not sure if it's a bug or not but I changed the logic so if we have both containers(non one-off and one-off), then choose the non one-off container.
https://github.com/docker/compose/pull/11995
Actually docker compose exec
should not target one-off containers, this seems like a bug we introduced, maybe some user start to rely on so #11995 could be a reasonable workaround
Description
When running a project using
docker compose up
and subsequently creating a one-off container usingdocker compose run <service>
, runningdocker exec <service>
will use the one-off container if a) it is newer than the managed container or b) the managed container is not running.Steps To Reproduce
Using the following
docker-compose.yaml
:Run the following commands:
The output of both
exec
commands should showyes
in the process list, indicating that it's running within the one-off container. I would expect it to either a) run in the managed container (sleep
would be in the process list) or b) printservice "bug" is not running
and exit.Compose Version
Docker Environment
Anything else?
Possibly related: #10359