Freed Dockers mounted hosts?

I just looked at my / var / lib / docker / volume folder and found that it was torn with folders called UUID Docker, each containing a config.json file with contents in lines

{"ID":"UUID","Path":"/path/to/mounted/volume","IsBindMount":true,"Writable":true} 

Where

 /path/to/mounted/volume 

- this is the path to the folder on the host that was installed in the docker container with the -v switch at some point. I have such folders related to the beginning of my experiments with Docker, i.e. About three weeks ago.

The containers in question were stopped, and dockers appeared long ago, so I don’t see these records not passing by their sale date. This begs the question - am I left to see an error, or do I need to manually drop such entries from / var / lib / docker / volumes?

+58
docker mounted-volumes
Jan 07 '15 at 5:13
source share
3 answers

For Docker 1.9 and there is a native path:

List all lost volumes with

$ docker volume ls -qf dangling=true

Eliminate all of them with

$ docker volume rm $(docker volume ls -qf dangling=true)

+127
Feb 01 '16 at 12:47
source share

In the Docker User Guide:

If you delete the containers that mount the volumes, including the original dbdata container or subsequent db1 and db2 containers, the volumes will not be deleted. To remove a volume from disk, you must explicitly call docker rm -v against the last container with a link to the volume. This allows you to update or efficiently transfer data volumes between containers. - source

This is intentional behavior to avoid accidental data loss. You can use a tool like docker-cleanup-volumes to clean unused volumes.

+28
Jan 07 '15 at 7:34
source share

For Docker versions 1.13+ and ce / ee 17+, use the volume prune command

 docker volume prune 

Unlike the dangling=true request, this will not remove the driver-based remote volumes.

+6
Mar 23 '17 at 23:04 on
source share



All Articles