User Tools

Site Tools


docker:volumes:remove_a_volume

Docker - Volumes - Remove a volume

Remove one or more specific volumes - Docker 1.9 and later

Use the docker volume ls command to locate the volume name or names you wish to delete.

Then you can remove one or more volumes with the docker volume rm command:

To list the volumes:

docker volume ls

To remove the volumes:

docker volume rm volume_name volume_name

Remove dangling volumes - Docker 1.9 and later

Since the point of volumes is to exist independent from containers, when a container is removed, a volume is not automatically removed at the same time.

When a volume exists and is no longer connected to any containers, however, it's called a dangling volume.

To locate them to confirm you want to remove them, you can use the docker volume ls command with a filter to limit the results to dangling volumes.

When you're satisfied with the list, you can add a -q flag to provide the volume name to docker volume rm:

To list the volumes:

docker volume ls -f dangling=true

To remove the volumes:

docker volume rm $(docker volume ls -f dangling=true -q)

Remove a container and its volume

If you created an unnamed volume, it can be deleted at the same time as the container with the -v flag.

Note that this only works with unnamed volumes.

When the container is successfully removed, its ID is displayed.

Note that no reference is made to the removal of the volume.

If it is unnamed, it is silently removed from the system.

If it is named, it silently stays present.

To remove:

docker rm -v container_name
docker/volumes/remove_a_volume.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki