In this tutorial, we will be showing you where the images Docker downloads are stored on your Linux machine.
With Docker, a container is made from what is called an image. An image is essentially the template from which the container is created. It is also what is downloaded from places like Docker Hub or the GitHub container repository or built from a DockerFile.
These images are stored locally on your Linux system, allowing Docker to create any desired containers speedily. Where these images are stored will differ slightly depending on the settings of your Docker installation.
Additionally, images are not stored by Docker as one big file system. They are instead stored as individual layers. The advantage of using layers to build an image is that Docker only needs to download the parts that have been updated. If you have multiple containers built off of the same base layers, Docker doesn’t need to download each part again.
There are a couple of things we should note before you continue. First, you should not make any changes to your Docker images using these folders. They are basically meant to be read-only directories. If you want to clean up your system and delete unused images, you should use Docker’s built in prune functionality.
Secondly, the folders are definitely not designed to be human-readable. Folders use the layer hash rather than a name that is easy for a user to quickly identify.
If you want a portable container you have built, you will want to use a repository like GitHub, Docker Hub, or the many other alternatives.
Locating Docker Images on Linux with some Simple Steps
By default, Docker keeps all of its images on Linux within the “/var/lib/docker/
” directory. Each image is stored within a folder that uses the name of the storage server.
The following sections will show you how to determine your storage driver and the exact folder you will want to look in for your images.
Determining the Storage Driver
1. Before we can tell you exactly where the Docker images are stored on your Linux system, you will need to know what storage driver your installation is using.
You can get Docker to print out information about your setup using the following command within the terminal.
docker info
2. You will be greeted with a chunk of information about your docker setup. While this might look overwhelming, there is only one option that you will actually require from this.
Client: Docker Engine - Community
Version: 27.1.2
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.16.2
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.29.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 29
Running: 10
Paused: 0
Stopped: 19
Images: 25
Server Version: 27.1.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
3. The one line that you are after in this file is the one that starts with “Storage Driver
“. This value tells you the storage driver Docker uses to handle your system’s images.
Storage Driver: overlay2
From this example, you can see the driver is “overlay2
“. This helps tell you the directory to look in for your Docker images.
overlay2
Another option that is output by this command is the Docker root directory. This is typically the same on every Linux-based system, but you can verify this by checking the “Docker Root Dir
” option.
Listing out the Location of your Docker Images on Linux
4. Now that we know the storage name, we can list out the contents of the directory where the Docker images are stored on our Linux system.
All we need to do to list the contents of this directory is to use the ls command on the following directory. Just ensure that you replace “<STORAGEDRIVER>
” with the name of the storage driver.
ls /var/lib/docker/<STORAGEDRIVER>
For example, our storage driver was set to “overlay2
” so the full directory was “/var/lib/docker/overlay2
“.
ls /var/lib/docker/overlay2
Below is an example of what you would see within this folder. Here, you are confronted with what might look like a random jumble of letters and numbers. These strings are the sha256 hash for that image layer.
These aren’t exactly made for humans to read and interact with. The intended method is to use the Docker CLI to see your available images.
012f8a597142b7b76b070108d5b4309d58d07828ac6c4d184b8708e8be31c018
013f8163305db4585e438a36c48d9eb018d7021efde8105524faea23e3786e94
013f8163305db4585e438a36c48d9eb018d7021efde8105524faea23e3786e94-init
01ad9bcda8f6bf8c411163c82dd4b72a344ba351d7b8884e3d7b35f331ce605e
0453de1f2cfa91f784aadab0e96fa0bdbe83cb0ef5edb73fd86989c05bfecf2d
04bd9a10d66b953a85128a0794729a4d5af8d6872dd56e0c5ba75ea74a31d364
04e0ebbe0d8ddc678206b7b6708a695eea22f5d7d5109448d9d79f94ca33a048
Conclusion
Hopefully, at this point in the guide, you will find out how to quickly see what Docker images are stored on your Linux system.
All your Docker images are kept within the Docker root directory, which in most Linux systems cases is at “/var/lib/docker/overlay2
“.
While you can find where images are stored on Linux, you can quickly see that the folder structure really isn’t intended for a human to interact with. They are mainly a holding ground to build your containers from. Any changes to Docker images should really be done through its command line interface.
Please use the comment below if you need help finding where images are stored on your Linux system.
If you found this quick guide to be helpful, we recommend checking out some of the other Docker guides we offer.