Where are Docker Images stored on your Docker host machine? This is a fairly common question and one I will aim to tackle here! The answer is that it depends on what system you are running docker on and which Docker storage driver you are using. You may be running Docker on Linux (which is what I’m using for this article) or Windows or other. This article will show you how to find where the docker images are stored on your docker host system by showing you what commands you can run to get the information you need.
To get started, check out what images you currently have. You can view what Docker images you have on your system by running the docker images command:
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE python latest 9038c75f5336 12 hours ago 933MB nginx latest 5ad3bd0e67a9 2 days ago 127MB nginx 5a3221f0137b 5 months ago 126MB ubuntu latest a2a15febcdf3 5 months ago 64.2MB
Using Docker Info to Find the Docker Image Storage Location
To find where your images are stored, you can first run the Docker info command, which will list the location of your Docker root directory:
# docker info
This will output quite a lot of information, but you can make it a little easier to find what we are looking for by searching specifically for the root directory line using grep:
$ docker info | grep "Docker Root Dir" Docker Root Dir: /var/lib/docker
Where are Docker Images Stored on Linux
As you can see from the output above, on my Centos 7 system, the Docker root directory is in /var/lib/docker. Looking inside, there will be a bunch of directories:
drwx------. 2 root root 23 Jan 16 2019 builder drwx------. 4 root root 87 Jan 16 2019 buildkit drwx------. 3 root root 19 Jan 16 2019 containerd drwx------. 3 root root 77 Aug 27 11:33 containers drwx------. 5 root root 50 Aug 20 14:03 devicemapper drwx------. 4 root root 35 Aug 20 13:36 image drwxr-x---. 3 root root 18 Jan 16 2019 network drwx------. 4 root root 30 Jan 16 2019 plugins drwx------. 2 root root 6 Jan 24 11:12 runtimes drwx------. 2 root root 6 Jan 16 2019 swarm drwx------. 2 root root 6 Jan 24 11:12 tmp drwx------. 2 root root 6 Jan 16 2019 trust drwx------. 2 root root 30 Aug 20 13:36 vfs drwx------. 2 root root 24 Jan 16 2019 volumes
Looking inside the images directory on my system, there are two subdirectories:
drwx------. 5 root root 77 Aug 27 11:21 devicemapper drwx------. 5 root root 77 Aug 20 13:36 vfs
These relate to the storage driver that Docker is using for storage. On my Centos system this is devicemapper, on the version of Docker that I am using. However, on a different host OS you may find this to be overlay, overlay2, btrfs, devicemapper or zfs. Note that you can manually set the driver – I’ve written an article covering this here. As mentioned in that article, you can easily check what driver you are currently using by running:
$ docker info | grep "Storage Driver"
Looking inside my /var/lib/docker/image/devicemapper directory I can see:
drwx------. 4 root root 56 Aug 20 14:03 distribution drwx------. 4 root root 35 Jan 16 2019 imagedb drwx------. 5 root root 42 Aug 20 14:03 layerdb -rw-------. 1 root root 1.5K Jan 24 11:39 repositories.json
Running a ‘du –summarize -h’ here shows that this isn’t the location of the image file data as the total storage used amounts to only 3.1M.
du --summarize -h 3.1M .
Instead, this location contains information about the docker images. The image data itself can be found under the folder corresponding to the storage driver being used. So, in my case, I need to look into /var/lib/docker/devicemapper. Navigating to this directory, then running ‘du’, gives the following output:
$ du -h --summarize 1.5G .
Of the subdirectories here, the data one stores the images and the metadata directory stores the image metadata.
/var/lib/docker/devicemapper/devicemapper/data - stores the images /var/lib/docker/devicemapper/devicemapper/metadata - contains the metadata
I ran through all the above on a Centos system. To summarise, the docker image locations on other popular Linux distributions are:
- Ubuntu:
/var/lib/docker/
- Fedora:
/var/lib/docker/
- Debian:
/var/lib/docker/
Where are Docker Images Stored on Windows ?
On windows, the default location for docker images is C:\ProgramData\DockerDesktop
What about Mac ?
On a Mac, the default location for Docker images is ~/Library/Containers/com.docker.docker/Data/vms/0/. Note than on Windows and Mac, Docker runs Linux containers in a virtual environment.
Hopefully this has helped you better understand how and where Docker stores its data, and helps answer the question of where Docker images are stored on your Docker host system.
Learning Docker?
If you are starting out, then I highly recommend this book.
Are you thirsty for more?
Then it’s time to take your Docker skills to the next level with this book (It’s my favorite) and, check out my page on Docker Certification.