82

Where are the docker images located once they are downloaded from docker hub in Mac OSX. For example if I run a command like:

docker run hello-world

the image is downloaded and the container is run but where is that image located on my system?

Note: Where are Docker images stored on the host machine? This question has answers related to linux machine, mainly. The answers for Mac OS X are considering that boot2docker is being used alongside docker installation, which is not the case for me.

9
  • 2
    Nope, it's not. That question specifies the location in a linux machine. The answers related to Mac OS X are considering the use of boot2docker alongside docker installation.
    – mbbce
    Commented Sep 16, 2015 at 10:26
  • 1
    How are you using Docker on the Mac then? You either have to use boot2docker or docker-machine...
    – nwinkler
    Commented Sep 16, 2015 at 11:35
  • 1
    I am using the docker toolbox for Mac OS X, which has docker-machine if I am not wrong
    – mbbce
    Commented Sep 16, 2015 at 12:35
  • I guess the answer from the linked question applies then. docker-machine is using a VM (called dev by default) that holds all of the images. Internally, docker-machine is still using the boot2docker VM, at least at the moment...
    – nwinkler
    Commented Sep 16, 2015 at 13:54
  • There is nothing in my VirtualBox VMs folder. However, I think that this said VM is now in /Users/<username>/.docker/machine/machines/default/ directory. I was under the impression that there might exist separate files for each container.
    – mbbce
    Commented Sep 16, 2015 at 14:23

11 Answers 11

95

And if you are using Docker for Mac then the location is again different, namely:

/Users/MyUserName/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
4
  • 29
    is there a way to view the content of Docker.qcow2 like view the content of the containers directly on disk?
    – Jas
    Commented Jan 15, 2017 at 14:12
  • 1
    You have to list folders from the VM, just try this command : docker run --rm -it -v /:/vm-root alpine:edge ls -l /vm-root/var/lib/docker Commented Mar 22, 2018 at 20:16
  • 1
    You can also use screen: screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty. See gist.github.com/BretFisher/5e1a0c7bcca4c735e716abf62afad389 Commented Jul 5, 2018 at 15:40
  • running cmd on my machine Darwin MyName 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64 this was not the case. Close but no cigar :-) Commented Jan 22, 2021 at 10:52
68

The Disk image location can also be seen (as mentioned in the docs) by selecting Preferences->Advanced menu from the Docker toolbar icon (works in Docker-CE v17):

Docker->Preferences->Advanced

Update: As mentioned by @udondan Docker now has a separate 'Disk' tab in Preferences where it shows the disk image location:

Docker->Preferences->Disk

3
  • A picture of proof is better than a thousand words! Thanks! Commented Aug 5, 2017 at 4:51
  • 2
    It now is located in its own tab "Disk".
    – udondan
    Commented Apr 4, 2018 at 8:34
  • 1
    If I have multiple images, how do I extract the image from the qcow2 file?
    – Sid
    Commented Apr 30, 2018 at 9:31
29

For someone who is using Docker toolbox (that uses docker-machine), the answers concerning boot2docker on Mac OS X is not valid. The docker-machine VM is called "default" and it exists in /Users/<username>/.docker/machine/machines/default/ directory.

Note: I have also added this answer to this question: Where are Docker images stored on the host machine? but I am answering here as well so that it's easier to find the answer for someone specifically looking for Mac OS X and new version of Docker.

2
  • 2
    Using all default settings, I just installed Docker Toolbox 1.10.2 on OS X El Capitan (10.11.3), and found the docker-machine located at a slightly different position: /Users/MyUserName/.docker/machine/machines/default/
    – fsteff
    Commented Feb 27, 2016 at 21:24
  • Thanks for adding this here. After moving to Docker for Mac, Docker Toolbox never cleaned up the old data, so the 34G image was still sitting in that folder.
    – jwadsack
    Commented Nov 3, 2016 at 6:06
14

The docker images are stored in a different location on the Mac with Docker Desktop, different to where they are stored on other Linux systems.

Extract from Docker documentation (retrieved 25 March 2020 from https://docs.docker.com/docker-for-mac/space/ )

Docker Desktop stores Linux containers and images in a single, large “disk image” file in the Mac filesystem. This is different from Docker on Linux, which usually stores containers and images in the /var/lib/docker directory.

On my Mac with MacOS 10.14.6 Mojave, running Docker version 19.03.8 that single large file can be found at:

~/Library/Containers/com.docker.docker/Data/vms/0/data/Docker.raw
9

To elaborate on how to open these folders in case you are getting now directory because it is a mounted on virtual host not your Mac regular volume

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty 

ls -ltrh /var/lib/docker/volumes

Answer from here

If you want to control the volume from your mac, you can map it while you are creating the container

docker run -it --name voltest2 -v /path/to_mac/directory/MyHostDir:/mydata centos:latest /bin/bash

which will map a directory mydata on your container to a directory /path/to_mac/directory/MyHostDiron your mac

3

In my case (Mavericks / docker brew installed / Image name: default) is located under

/Users/<Username>/.docker/machine/machines/.

(You gotta use terminal and not finder to see it. )

   ls -lah /Users/Mitsos/.docker/machine/machines/
    total 0
    drwx------   3 Mitsos  staff   102B Dec  8 19:03 .
    drwxr-xr-x   5 Mitsos  staff   170B Sep 22 13:52 ..
    drwx------  13 Mitsos  staff   442B Dec  8 19:04 default
3

In my case, I want to locate the docker images and copy them to another location.

Use docker save to Save one or more images to a tar archive (streamed to STDOUT by default)

Link: https://docs.docker.com/engine/reference/commandline/save/

1

This answer doesn't concern the "boot2Docker" version for MAC. Here I have the Version 17.12.0-ce-mac55, you have to keep in mind that Docker is still running in a VM, the system paths are relative to the VM and not from the Mac Osx system. As it says all is contained in a VM file :

/Users/MyUserName/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2

Try to run Alpine image with this volume option and the ls command you are able to list the VM host:

docker run --rm -it -v /:/vm-root alpine:edge ls -l /vm-root

After this just try :

docker run --rm -it -v /:/vm-root alpine:edge ls -l /vm-root/var/lib/docker

Now, you are able to list the docker folder from the WM host

1

In Docker Desktop version 2.2.0.4, check out the screenshot below.

enter image description here

1

On my Mac with MacOS 10.15.4 Catalina, running Docker 19.03.8 / Docker Desktop 2.3.0.2(45183) the Docker.raw is located here:

~/Library/Containers/com.docker.docker/Data/vms/0/Docker.raw 
0

There's some information on this here. You can check the location by running

docker info| grep "Docker Root Dir"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.