Please note: the described process should be virtually identical for the Docker for Windows users, but I unfortunately don’t own a Windows and can’t test it. Any comments would be greatly appreciated, if somebody wants to try this approach on a Windows.

Docker for Mac is a great way of using Docker on a modern Mac that gives you fully functional Docker environment, in a very easy way. It is not a “native” solution however, meaning: there is still an, albeit lightweight, VM running on your Mac. For the most part this fact is completely transparent to you, especially compared to earlier solution of running full VMs with VirtualBox, Parallels or VMWare, but in some cases you will still run into the reality of there being a VM. One such case is when you are working with Docker volumes.

Let’s assume you have a docker-compose file that creates multiple volumes. For the sake of argument let’s assume you are running Node Bootstrap-created microservice. Out of the box, such microservice will have some locally mounted volumes for code-editing and some data volumes for database. What if you wanted to inspect them directly? Docker provides a command to see all volumes:

→ docker volume ls
local               4cf5..708
local               msfirst_ms_nb_example_db_data

and then inspect them, using a command like:

→ docker volume inspect msfirst_ms_nb_example_db_data

with output such as:

        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "msfirst",
            "com.docker.compose.volume": "ms_nb_example_db_data"
        "Mountpoint": "/var/lib/docker/volumes/msfirst_ms_nb_example_db_data/_data",
        "Name": "msfirst_ms_nb_example_db_data",
        "Options": {},
        "Scope": "local"

Notice the Mountpoint attribute? It all sounds really promising until you try to ls /var/lib/docker/volumes.. only to find that there is no such folder on your Mac. Now that is a disappointment! Except, we just need to realize that the /var/lib/docker is a path in the Docker host VM, not on our Mac. And there is actually a relatively straightforward way to get to it. We will see how to do exactly that in a second, but before we do, to make things slightly more convenient, and reduce on typing, you should create an alias:

alias dm-disk='docker run --rm -it -v /:/docker alpine:edge $@'

after which you could see the path that docker volume inspect returns with a command that looks something like the following:

dm-disk ls -l /docker/var/lib/docker/volumes/msfirst_ms_nb_example_db_data/_data

What Did Just Happen?

We ran a temporary, tiny container, in which we mounted the root of the host VM to the /docker path. Once we have such container, we can run all kinds of commands inside it to inspect Docker volumes. For instance, to see all available volumes on the host you could run:

dm-disk ls -l /docker/var/lib/docker/volumes/

That’s about it.