ubuntu:docker:remove_a_volume
Differences
This shows you the differences between two versions of the page.
ubuntu:docker:remove_a_volume [2019/11/27 01:13] – created peter | ubuntu:docker:remove_a_volume [2020/04/15 22:06] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Ubuntu - Docker - 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. | ||
- | |||
- | To list the volumes: | ||
- | |||
- | <code bash> | ||
- | docker volume ls | ||
- | </ | ||
- | |||
- | |||
- | To remove the volumnes: | ||
- | |||
- | <code bash> | ||
- | 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 list the volumes: | ||
- | |||
- | <code bash> | ||
- | docker volume ls -f dangling=true | ||
- | </ | ||
- | |||
- | To remove the volumes: | ||
- | |||
- | <code bash> | ||
- | 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. | ||
- | |||
- | To remove: | ||
- | |||
- | <code bash> | ||
- | docker rm -v container_name | ||
- | </ | ||
ubuntu/docker/remove_a_volume.1574817237.txt.gz · Last modified: 2020/07/15 09:30 (external edit)