Where is /var/lib/docker on Mac/OS X

As of 2021 is the dance going, Mac Users get easily to the VM with the documented methods, and hence to the volumes.

There's a way Rocky Chen found to get inside the VM in Mac. With this you can actually inspect the famous /var/lib/docker/volumes.

docker run -it --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh

Let examine the method:

  • -it goes for Keep STDIN open even if not attached + Allocate pseudo-TTY
  • --privileged "gives all capabilities to the container. Allows special cases like running docker" .
  • --pid defines to use the host VM namespace.
  • debian the actual image to use.
  • nsenter a debian's tool to run programs in different namespaces
  • -t is the target PID
  • -m mount the provided PID namespace.
  • -u enter the Unix Time Sharing (UTS) namespace.
  • -n enter the provided PID network namespace.
  • -i enter the provided PID IPC namespace.

Once run, go to /var/lib/docker/volumes/and you'll find your volumes.

The next question to address for me is:

How to take those volumes and back them up in the host?

I appreciate ideas in the comments!

UPDATE FOR VSCODE USERS

If you downloaded the Official Docker extension, sun will shine for you.

Docker Extension

Just inspect the volumes in Visual Studio Code. Right-click the files you want to have in your local, and download them. That easy!

2nd UPDATE

As of July 2021, Docker Desktop for Mac is announcing we will be able to access volumes directly from the GUI, but only for Pro and Team accounts.

enter image description here


As mentioned in the above answers, you will find it in:
screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty

Once you get the tty running you can navigate to /var/lib/docker