This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
No way to not remove depended on services with docker compose rm
#1572
Labels
compatibility
Compatibility with docker-compose
Description
The behavior of
docker compose rm
differs fromdocker-compose rm
in how dependent services are handled. Previously,docker-compose rm <service>
would only attempt to remove the specified service, but,docker compose rm <service>
will attempt to remove the specified service and all other services it depends on.Steps to reproduce the issue:
app
) and a database service (db
), where the web application depends on the database service via thedepends_on
property indocker-compose.yml
.docker compose up
to create the containers and initialize the database.docker compose rm app
.Describe the results you received:
Both
app
anddb
are removed. Also, becausedb
is removed, any anonymous volumes, such as ones holding the actual database data, are removed.Describe the results you expected:
Only
app
is removed.Additional information you deem important (e.g. issue happens only occasionally):
This is a surprising change in behavior compared to the old
docker-compose
CLI. Yes, it did prompt me with a confirmation about the containers being removed, but because I was used to the old behavior, I enteredY
out of habit. This is particularly annoying in my case because my database service is just the vanilla, official Postgres Docker image, which defines an anonymous volume holding the actual database data, and removing thedb
service caused the volume to be removed. Nothing critical was lost in my case, since it was just a development database, but it is a bit frustrating to lose it.Also, until I encountered this, I had no idea that
docker compose
was a separate command-line program thandocker-compose
and that they would have different behavior. I really think the Docker for Mac release notes and messages fromdocker-compose
that tell you to instead usedocker compose
should make it clearer that these two tools are different so that users will understand that they may need to be careful about any specific behavior that they were used to.As far as I can tell, there is no way to remove just the
app
service and not the other services it depends on, since I don't see any documented options for doing so, so until then, I think I will have to continue usingdocker-compose rm
.Output of
docker version
:Output of
docker context show
:You can also run
docker context inspect context-name
to give us more details but don't forget to remove sensitive content.Output of
docker info
:Additional environment details (AWS ECS, Azure ACI, local, etc.):
The text was updated successfully, but these errors were encountered: