Closed bkumar08 closed 2 months ago
I am observing the same issue in latest docker version 25.0.3 [root@ip-10-82-8-97 ec2-user]# docker version Client: Version: 25.0.3 API version: 1.44 Go version: go1.20.12 Git commit: 4debf41 Built: Mon Feb 12 00:00:00 2024 OS/Arch: linux/amd64 Context: default
Server: Engine: Version: 25.0.3 API version: 1.44 (minimum version 1.24) Go version: go1.20.12 Git commit: f417435 Built: Mon Feb 12 00:00:00 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.7.11 GitCommit: 64b8a811b07ba6288238eefc14d898ee0b5b99ba runc: Version: 1.1.11 GitCommit: 4bccb38cc9cf198d52bebf2b3a90cd14e7af8c06 docker-init: Version: 0.19.0 GitCommit: de40ad0
This is the expected behavior; docker does not delete volumes by default (even if they are anonymous volumes); the only exception here is when running a container with the --rm
option set, which deletes both the container and anonymous volumes associated with it when the container exits; https://docs.docker.com/reference/cli/docker/container/run/#rm
To do the same when manually deleting a container, use the -v
/ --volumes
options on docker rm
/ docker container rm
; https://docs.docker.com/reference/cli/docker/container/rm/#volumes
Note that this will not delete "named" volumes (volumes that were explicitly created with a name).
Also note that Docker 20.10 reached EOL, and is no longer maintained; if possible, I'd recommend upgrading to a currently supported version.
I'll close this ticket, because this looks to be working as expected, but feel free to continue the conversation.
Description
Docker volumes are created only for images that have the VOLUME instruction, such as 'vault'. For example, if you pull any image that has a volume and run a container from it, the volume will be created automatically. However, when you delete the container from the host, the volume should also be deleted. But docker service is not deleting them automatically, resulting in an increase in file count and ultimately consuming disk space.
To fix this issue, we have to manually clean up from the host (docker volume rm $(docker volume ls -q)), which is not the expected behavior. Docker should manage this internally; whenever an associated container gets deleted, all volumes should also be deleted from the host belongs to deleted containers.
Reproduce
VOLUME NAME LINKS SIZE 6c2fc8c9a20ebbf4d344aca9b0c72c388188ee36d65eb8fe7afa949fefd49152 0 0B 8e9ceb5c2149cc5077f1d305572d685cdc11de32c74d16e9522aae5a1a08497c 0 2.22GB 2bef84507c17587ecdca16fe24fe7af25f98943c61031a76d44ffecc15c9859e 0 3.215GB
Expected behavior
whenever an associated container gets deleted, all volumes should also be deleted from the host belongs to deleted containers
docker version
docker info
Additional Info
No response