Reputation: 52253
I have a volume that isn't recognized as orphaned:
>docker volume ls -qf dangling=true
>docker volume ls
DRIVER VOLUME NAME
local 70cb...
I assume it's used by one of my containers, but how can I find out which one?
Upvotes: 0
Views: 49
Reputation: 6534
I don't believe there's a way to ask a volume what containers belong to, but you can ask what volumes a container has a reference to. You can loop over each container and look for the volume in question. For example, this bash loop around the docker CLI should do the trick:
export volume=70cb
for container in $(docker ps -aq);
do docker inspect $container \
| grep $volume \
&& echo $container matches;
done
This, of course, is prone to false positives in the off chance than any of the docker inspect
output arbitrarily matches the value you pass in for the volume, but it is a good starting point.
Upvotes: 1