If you’ve ever worked with Docker and wondered where all those pulled images and built containers are stored on your system—you’re not alone. Docker abstracts away many of the underlying details, but understanding where Docker images are stored on the host machine is important for debugging, disk space management, and system optimization.
In this blog post, we’ll explore where Docker stores images, how to locate them, and what you should (and shouldn’t) do with those files.
🐳 What Are Docker Images?
Docker images are read-only templates used to create containers. They consist of layers and metadata stored by the Docker Engine. Every time you pull an image (docker pull
) or build one (docker build
), Docker saves it on your host.
🗂️ Default Docker Image Storage Location
By default, Docker stores images and other data in this location:
/var/lib/docker/
This directory contains all Docker-related storage, including:
- Images
- Containers
- Volumes
- Build cache
- Networking configs
Inside /var/lib/docker/
, image data is stored under:
/var/lib/docker/overlay2/
If you’re using a different storage driver (like
aufs
,btrfs
, orzfs
), the directory name will match that driver.
🛠 How Docker Stores Images (Layered File System)
Docker uses a layered file system:
- Each layer is a directory under
/var/lib/docker/overlay2/
(or your storage driver). - These layers are shared across images to reduce duplication.
- When you build or pull an image, it stores the image as a set of layers, each identified by a hash.
Docker also maintains metadata about images under:
/var/lib/docker/image/overlay2/imagedb/
This metadata helps Docker manage and track images.
🔍 View Docker’s Storage Driver
To find out which storage driver Docker is using, run:
docker info
Look for the line:
Storage Driver: overlay2
The driver determines the internal storage structure.
🧑💻 Can You Manually Edit or Delete Image Files?
No—it’s not recommended.
- Docker uses a complex layered structure with dependency chains.
- Manually modifying files in
/var/lib/docker/
can corrupt your Docker engine and cause unpredictable behavior. - Use
docker
commands to manage images safely.
Recommended Commands:
- List images:
docker images
- Remove specific image:
docker rmi <image_id>
- Remove all unused images:
docker image prune -a
- See disk usage:
docker system df
📁 Custom Docker Image Storage Location
You can change the default image storage directory by modifying the Docker daemon configuration.
Step 1: Create a new directory (e.g., on another disk):
sudo mkdir -p /mnt/docker-data
Step 2: Edit Docker’s daemon.json:
sudo nano /etc/docker/daemon.json
{
"data-root": "/mnt/docker-data"
}
Step 3: Restart Docker:
sudo systemctl restart docker
Docker will now use the new location for all images, containers, and volumes.
📝 Conclusion
Docker stores all its images and data in a hidden system directory—typically under /var/lib/docker/
. While it’s technically possible to explore that directory, it’s best to manage everything through Docker commands for safety and reliability.
If disk space becomes an issue or you need more control over storage, you can configure Docker to use a different path for storing its data.