Reputation: 1277
My volume is defined like below: How can I remove that host mounted named volume ? docker volume prune or rm or docker-compose down -v
only deletes the volume from /docker/lib/volumes dir but doesn't delete from the host where it was mounuted ?
volumes:
drupal:
driver: local
driver_opts:
type: bind
device: $PWD/code/drupal
o: bind
Upvotes: 1
Views: 3166
Reputation: 2372
There are no commands in docker for deleting volumes which are not managed by docker. You will have to use usual os command(rm -rf) to remove them.
You can use below command to get the container id, source directory and destination directory of all the containers that are running with Volume Type "Bind" which is managed by you. After checking the output you decide what you want to do with the directories
[root@localhost~]# for id in $(docker ps -q); do docker inspect ${id} | jq '.[] | select(.Mounts[].Type=="bind") | [.Id, .Mounts[].Source, .Mounts[].Destination]'; done
[
"c758b5ea72406d4912741002bcbef25ea7f05b55f8b5863d82c81a046292b12b",
"/mnt",
"/mnt1"
]
where,
Container id = c758b5ea72406d4912741002bcbef25ea7f05b55f8b5863d82c81a046292b12b
Source Directory which is Mounted on Host = /mnt
Target Directory which is Mounted on container = /mnt1
Upvotes: 1