Volumes can be used by one or more containers, and take up space on the Docker host. Volumes are never removed automatically, because to do so could destroy data.
List volumes
docker volume ls
Prune all volumes
docker volume prune
By default, you are prompted to continue. To bypass the prompt, use the -f
or --force
flag.
By default, all unused volumes are removed. You can limit the scope using the --filter
flag. For instance, the following command only removes volumes which are not labelled with the keep
label:
Prune volumes with filters
docker volume prune --filter "label!=keep"
Other filtering expressions are available. See the docker volume prune
reference for more examples.