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
On a mac our docker files are located inside of a virtual machine which is located in our user library directory:
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
Now to get to the root directory
/var/lib/docker we must access the docker virtual machine being used on our mac.
Use the terminal application screen.
You should see a screen, where you can enter the command
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:
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
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
If the default storage driver overlay2 was used, then your Docker images are stored in the directory
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.