vegetaaaaaaa@lemmy.worldtoSelfhosted@lemmy.world•Why use Named volume vs Anonymous volume in Docker?English
18·
7 days ago- step 1: use named volumes
- step 2: stop your containers or just wait for them to crash/stop unnoticed for some reason
- step 3: run
docker system prune --all
as one should do periodically to clean up the garbage docker leaves on your system. Lose all your data (this will delete even named volumes if they are not in use by a running container) - step 4: never use named or anonymous volumes again, use bind mounts
The fact that you absolutely need to run docker system prune --all
regularly to get rid of GBs of unused layers, test containers, etc, combined with the fact that it deletes explicitely named volumes makes them too unsafe for my taste. Just use bind mounts.
/var/lib/docker/volumes/
by defaultStill, use bind mounts. Named or anonymous volumes are only good for temporary junk.