DevOps 1 min read

[Docker] Removing Anonymous Volumes

Anonymous volumes are removed automatically, when a container is removed.

This happens when we start / run a container with the --rm option.

If we start a container without that option, the anonymous volume would NOT be removed, even if we remove the container (with docker rm ...).

Still, if we then re-create and re-run the container (i.e. you run docker run ... again), a new anonymous volume will be created. So even though the anonymous volume wasn't removed automatically, it'll also not be helpful because a different anonymous volume is attached the next time the container starts (i.e. you removed the old container and run a new one).

Now we just start piling up a bunch of unused anonymous volumes - you can clear them via docker volume rm VOL_NAME or docker volume prune.