Orphaned Docker mounted host volumes?

I just inspected my /var/lib/docker/volumes folder and discovered that is bursting with folders named as Docker UUIDs each of which contain a config.json file with contents along the lines of



  • No `echo` Output in `RUN` Command
  • Restart docker container from another container
  • How can I find out how much space is used by my container images from the Google Container Registry
  • Download failure within official ubuntu docker images on Ubuntu 14.04 host
  • Bitbucket Pipelines - access to another container
  • Dockerfile failed because of E: Version x for y was not found
  • /path/to/mounted/volume

    is the path to the folder on the host that was mounted on to a docker container with the -v switch at some point. I have such folders dating back to the start of my experiments with Docker, i.e. about 3 weeks ago.

    The containers in question were stopped and docker rm’ed a long time ago so I cannot see that those entries are not past their sell-by date. This begs the question – is the left over I am seeing a bug or does one need to manually discard such entries from /var/lib/docker/volumes?

  • Raspberry pi zero Docker can't start container
  • Run Command Inside of Docker Container Using Ansible
  • Mongo running in linux container, stop taking connection.
  • How can I delete Docker's images?
  • How to repair docker or reinstall it?
  • Alternatives to inotify for watching file changes in a NFS volume in a Docker container?
  • 3 Solutions collect form web for “Orphaned Docker mounted host volumes?”

    For Docker 1.9 and up there’s a native way:

    List all orphaned volumes with

    $ docker volume ls -qf dangling=true

    Eliminate all of them with

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

    From the Docker user guide:

    If you remove containers that mount volumes, including the initial dbdata container, or the subsequent containers db1 and db2, the volumes will not be deleted. To delete the volume from disk, you must explicitly call docker rm -v against the last container with a reference to the volume. This allows you to upgrade, or effectively migrate 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 out unused volumes.

    For Docker 1.13+ and the ce/ee 17+ release numbers, use prune

    docker volume prune

    Unlike the dangling=true query, this will not remove “remote” driver based volumes.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.