> For the complete documentation index, see [llms.txt](https://tuonioooo-notebook.gitbook.io/docker/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tuonioooo-notebook.gitbook.io/docker/advanced/docker-find-volume-container-mapping.md).

# docker-find-volume-container-mapping

```bash
#!/bin/bash
# 脚本批量查找每个卷对应的容器：
echo "Volume -> Container mapping:"
echo "=========================="

for volume in $(docker volume ls -q); do
    containers=$(docker ps -a --filter volume=$volume --format "table {{.Names}}")
    if [ -n "$containers" ] && [ "$containers" != "NAMES" ]; then
        echo "Volume: $volume"
        echo "Containers: $containers"
        echo "---"
    fi
done
```

[脚本](https://github.com/tuonioooo/docker/blob/master/sh/find-volume-container-mapping.sh)
