Checking the contents of a Docker volume

2022-01-29

Here’s a note on how to check the contents of a docker volume:

Case 1: Use the volume name

docker run -it --rm -v my_volume:/app busybox

This runs a container that will be auto-removed on exit, mounting my_volume in /app. Connect to the container and open a shell:

docker exec -it <container_id> sh

Case 2: Mount all volumes from a running container

docker run -it --rm --volumes-from my_container:ro busybox

Same as above, but mounting all volumes from my_container in their “natural” location.

Further reading: