DEV Community

Moya Richards
Moya Richards

Posted on

How to find the storage location of Docker images and containers on a mac

Finding the location of docker images is a chore on a mac. Usually on most systems, you can see where the images and containers are located by running the command docker info but no, that does not work on a mac. You see that command will tell you that the root directory is located at /var/lib/docker , which on a mac is a non-existent directory.

There are two primary ways to get to this directory. Try option 1 first, if it does not work try option 2

Here is a little background information on the docker directory

On a mac our docker files are located inside of a virtual machine which is located in our user library directory: ~/Library/Containers/com.docker.docker/

This directory is easy to get to from the terminal, but if you try to get there via the finder you might notice that com.docker.docker does not appear visually under that directory name. When you navigate to ~/Library/Containers you will see the folder name Docker instead. Take note, that is the com.docker.docker directory

docker directory

Now to get to the root directory /var/lib/docker we must access the docker virtual machine being used on our mac.

Option 1

Use the terminal application screen.

screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
Enter fullscreen mode Exit fullscreen mode

You should see a screen, where you can enter the command

cd /var/lib/docker
Enter fullscreen mode Exit fullscreen mode

Option 2

Now if you are unlucky and you get a permission denied error, you will need to try to access the docker virtual machine through a docker image:

Alt Text

To get around this error, we will install a debian docker image, run it, then enter the container with the nsenter tool

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

This will open the debian image and allow us to browse around the docker files via the sh shell

Now that the shell is available. let's type the command

cd /var/lib/docker
Enter fullscreen mode Exit fullscreen mode

If the default storage driver overlay2 was used, then your Docker images are stored in the directory /var/lib/docker/overlay2

docker files

To get a detailed explanation of the docker run flags, type docker run --help command in the terminal.


Learn more about nsenter linux tool on the redhat linux website.

Getting path and accessing persistent volumes in Docker for Mac by Tim Kamanin

Github : docker can't access volume with screen

Top comments (4)

itsvikasgupta profile image

On Mac os ventura version 13.0.1 and docker app version 4.14.0 (91374), the screen command just exits after a few seconds because the file ~/Library/Containers/com.docker.docker/Data/vms/0/tty doesn't exist.

puffycavy profile image

I couldn't find the tty on my Mac OS 12.6.3 either. Waiting for more updates.

davidjmcclelland profile image
David J McClelland

The location might have changed again since posting this.
Monterey 12.4 - no container dir found under any of the paths mentioned. I still haven't found where they are stored.

xipniekneuij profile image
Niek Neuij

Still in the same spot.

It's confusing because the path is:

But Finder shows it as:
Macintosh HD ∙ Users ∙ $user ∙ Library ∙ Containers ∙ Docker ∙ Data