You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Need to double-check if this was by design, but docker rm -v (remove container including volumes attached to it) only removes anonymous volumes, but not named ones. However, the flag description does not mention this;
docker container rm --helpUsage: docker rm [OPTIONS] CONTAINER [CONTAINER...]Remove one or more containersOptions: -f, --force Force the removal of a running container (uses SIGKILL) -l, --link Remove the specified link -v, --volumes Remove the volumes associated with the container
Steps to verify the current behavior:
docker run -d --name mycontainer1 -v /anonymous -v namedvol1:/namedvol nginx:alpine
docker run -d --name mycontainer2 -v /anonymous -v namedvol2:/namedvol nginx:alpine
docker volume ls
DRIVER VOLUME NAME
local 547d032c5571241ec33b6064dcaef1116c646b8a7e590a18bc56da9a2a22ddab
local 402827d64bced57d80125e52606d6b394c651c138cb829587798b041357523c2
local namedvol1
local namedvol2
Removing mycontainer1 keeps all volumes associated with the container:
docker rm -f mycontainer1
docker volume ls
DRIVER VOLUME NAME
local 547d032c5571241ec33b6064dcaef1116c646b8a7e590a18bc56da9a2a22ddab
local 402827d64bced57d80125e52606d6b394c651c138cb829587798b041357523c2
local namedvol1
local namedvol2
Whereas using the -v option removes the anonymous volume, but keeps the named volume:
docker rm -fv mycontainer2
docker volume ls
DRIVER VOLUME NAME
local 547d032c5571241ec33b6064dcaef1116c646b8a7e590a18bc56da9a2a22ddab
local namedvol1
local namedvol2
The text was updated successfully, but these errors were encountered:
Need to double-check if this was by design, but
docker rm -v
(remove container including volumes attached to it) only removes anonymous volumes, but not named ones. However, the flag description does not mention this;Steps to verify the current behavior:
Removing
mycontainer1
keeps all volumes associated with the container:Whereas using the
-v
option removes the anonymous volume, but keeps the named volume:The text was updated successfully, but these errors were encountered: