79

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.

Community
  • 1
  • 1
mbbce
  • 2,245
  • 1
  • 19
  • 31
  • 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 Sep 16 '15 at 10:26
  • 1
    How are you using Docker on the Mac then? You either have to use boot2docker or docker-machine... – nwinkler Sep 16 '15 at 11:35
  • 1
    I am using the docker toolbox for Mac OS X, which has docker-machine if I am not wrong – mbbce Sep 16 '15 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 Sep 16 '15 at 13:54
  • There is nothing in my `VirtualBox VMs` folder. However, I think that this said VM is now in `/Users//.docker/machine/machines/default/` directory. I was under the impression that there might exist separate files for each container. – mbbce Sep 16 '15 at 14:23
  • You might want to add that as an answer on the linked question. – nwinkler Sep 16 '15 at 14:26
  • I have added the answer there but I am also adding it here to facilitate if someone is looking specifically for Mac OS X and using new version of Docker. There are a lot of answers already posted in response to that question and they are not valid anymore. – mbbce Sep 17 '15 at 10:28
  • @MB_CE I too was under the impression I would find the images there; but I am also clueless. Where are the images we have stored in the mac? Won't be able to share those files to others? – Jikku Jose Dec 31 '15 at 11:33
  • If you're running on a mac - you should have vm's running under virtualbox. Can you see if virtualbox is on your machine, and if so, run it on it's own, and you'll see your vms... You'll also be able to see the location (by default, I think it's to ~/VirtualBox VMs – Daniel D Jan 01 '16 at 16:05

11 Answers11

94

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
Mike Park
  • 1,965
  • 1
  • 14
  • 10
  • 29
    is there a way to view the content of `Docker.qcow2` like view the content of the `containers` directly on disk? – Jas Jan 15 '17 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 – user1842947 Mar 22 '18 at 20:16
  • 1
    You can also use screen: `screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty`. See https://gist.github.com/BretFisher/5e1a0c7bcca4c735e716abf62afad389 – Etienne Neveu Jul 05 '18 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 :-) – Baron_Samedi Jan 22 '21 at 10:52
65

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

Pierz
  • 7,064
  • 52
  • 59
28

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.

DimaSan
  • 12,264
  • 11
  • 65
  • 75
mbbce
  • 2,245
  • 1
  • 19
  • 31
  • 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 Feb 27 '16 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 Nov 03 '16 at 06:06
12

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
jvarela
  • 3,744
  • 1
  • 22
  • 43
CyclingDave
  • 1,150
  • 1
  • 10
  • 22
8

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

Maged Makled
  • 1,918
  • 22
  • 25
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/

zhe
  • 57
  • 3
2

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
DimiDak
  • 4,820
  • 2
  • 26
  • 32
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

user1842947
  • 1,047
  • 1
  • 11
  • 16
1

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

enter image description here

f01
  • 1,738
  • 1
  • 18
  • 21
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 
Sylvain
  • 66
  • 6
0

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

docker info| grep "Docker Root Dir"
Mickael B.
  • 4,755
  • 4
  • 24
  • 48
nw79
  • 1