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.
The Official.NET Docker images are Docker images created and optimized by Microsoft. They are publicly available in the Microsoft repositories on Docker Hub. Each repository can contain multiple images, depending on.NET versions, and depending on the OS and versions (Linux Debian, Linux Alpine, Windows Nano Server, Windows Server Core, etc.). So the default location for containers and images is: – C: ProgramData docker. OK, let's run through the commands to create a new service pointing the container/images backend to a custom location.
To restart docker: right click on the docker icon at the bottom click on 'Restart'. Unluckily, the old images will stay in the old location and it's up to you to manually delete them after restarting docker. They are inside C:ProgramDataDockerwindowsfilter. I'm not sure if you can simply move them to the new location. Docker pull floydhub/dl-docker:cpu Now I can't seem to find where this image is located if I want to delete it and download another copy. When I used a the VMware virtual machine there would be a specific folder with the name designated by me. So how do I look for the folder containing this docker image?
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:
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:
The Official.NET Docker images are Docker images created and optimized by Microsoft. They are publicly available in the Microsoft repositories on Docker Hub. Each repository can contain multiple images, depending on.NET versions, and depending on the OS and versions (Linux Debian, Linux Alpine, Windows Nano Server, Windows Server Core, etc.). So the default location for containers and images is: – C: ProgramData docker. OK, let's run through the commands to create a new service pointing the container/images backend to a custom location.
To restart docker: right click on the docker icon at the bottom click on 'Restart'. Unluckily, the old images will stay in the old location and it's up to you to manually delete them after restarting docker. They are inside C:ProgramDataDockerwindowsfilter. I'm not sure if you can simply move them to the new location. Docker pull floydhub/dl-docker:cpu Now I can't seem to find where this image is located if I want to delete it and download another copy. When I used a the VMware virtual machine there would be a specific folder with the name designated by me. So how do I look for the folder containing this docker image?
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:
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:
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:
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:
Looking inside the images directory on my system, there are two subdirectories:
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:
Looking inside my /var/lib/docker/image/devicemapper directory I can see:
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.
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:
Of the subdirectories here, the data one stores the images and the metadata directory stores the image 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:ProgramDataDockerDesktop
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.
Where Is Docker Image File
Learning Docker?
If you are starting out, then I highly recommend this book.
Docker Where Is Image Stored
Are you thirsty for more?
Where Are Docker Images Located
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.