How to Inspect Docker Volume Data on MacOS

Docker is running in a virtual machine on MacOS. You may not realize this since it’s all managed under the hood. But this is a key difference when you want to dig deeper to inspect your docker image, volumes and etc. For example, if you run docker volume inspect xxxx on one of your volumes, you may find the mount point is /var/lib/docker/volumes/xxxx/_data. You cannot find this folder on your mac because it’s relative to VM of docker. In order to access it, you have to connect to the VM first.

1
2
$screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
$cd /var/lib/docker/volumes/xxxx/_data

You can even edit files in the VM and the change will be reflected in docker containers. To detach screen session, type Ctrl-a d.