Where are Docker images stored on the host machine?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Docker is a popular platform used for developing, shipping, and running applications in containers. It allows you to package your application along with its dependencies into a standardized unit known as a Docker image. These images are crucial because they form the blueprint of your applications and can be utilized to create containers.
Understanding where Docker stores these images on the host machine is quite beneficial for users, especially when managing disk space or optimizing performance. This article delves into the technical aspects of Docker image storage and provides insights into how you can interact with these storage layers.
Docker Image Storage Location
Docker images on Linux-based systems are typically stored under the Docker directory. On most Linux systems, the default storage location is /var/lib/docker. This directory houses the various subdirectories and files related to image storage, container data, and volume data.
By default, Docker uses a storage driver to manage these images and layers. Common storage drivers include OverlayFS, AUFS, and btrfs. The specific subdirectory for images varies based on the storage driver Docker has employed.
Main Subdirectories in /var/lib/docker
/var/lib/docker/image/: Houses image metadata such as manifests and repositories./var/lib/docker/overlay2/: Stores the read-only layers and the read-write layer for images when using OverlayFS./var/lib/docker/aufs/: Used instead of overlay2 on older releases of Docker or specific configurations./var/lib/docker/btrfs/: Applicable if the Btrfs storage driver is in use.
Storage Driver Details
OverlayFS
OverlayFS is a union filesystem that provides a way to superimpose a read/write layer atop several read-only layers. This is essential to Docker in maintaining an efficient layering of images where newer image layers are written over top of older ones, ensuring that identical layers are shared among containers to optimize storage.
- Directory:
/var/lib/docker/overlay2/ - Supports Fast Layer Operations: Each image consists of multiple layers that share a common base, which helps save space and speeds up operations.
AUFS
AUFS (Another Union File System) was historically the default storage driver before OverlayFS. While it is still supported, OverlayFS is preferred due to its integration within the Linux kernel.
- Directory:
/var/lib/docker/aufs/ - Features: Like OverlayFS, AUFS layers files over one another to provide a single unified view.
Btrfs
Btrfs is a copy-on-write filesystem ideal for Docker image storage. It allows snapshots, providing capabilities such as image rollback and restoration.
- Directory:
/var/lib/docker/btrfs/ - Advanced Features: Supports subvolumes and snapshotting, which can aid in better management and backup of images.
Changing Image Storage Location
Docker allows customization of the default storage location if required. This can be done by modifying the --data-root option in the Docker daemon's configuration file or by setting it as a command-line option.
To change the storage location:
- Configure the Docker Daemon:
- Modify or create the configuration file usually located at
/etc/docker/daemon.json. - Add the entry:
- Restart the Docker service:
Practical Examples
To inspect your current storage driver and the default storage location, use the command:
This command outputs which storage driver is currently in use. To see all images and their unique IDs:
Finally, to visualize image usage:
This provides statistics about image storage and allows for manual cleanup decisions.
Summary Table
Here is a summary of the key points regarding Docker image storage:
| Aspect | Details |
| Default Linux Path | /var/lib/docker |
| Main Drivers | OverlayFS, AUFS, Btrfs |
| Key Directories | overlay2, aufs, btrfs |
| Customization | Change via daemon settings
or --data-root |
| Command Examples | Inspect driver: docker info
List IDs: docker images -q |
By understanding the structure and configuration options regarding Docker image storage, you gain better control over resource management, enabling the delivery of reliable and efficient containerized applications.
Related reading
- Where can I find the sha256 code of a docker image?
- Where is docker image location in Windows 10?
- Where is Kubernetes storage location of a Persistent Volume on Docker Desktop for mac?
- where is “registry-1.docker.io” ?
- Where are helm charts stored locally?
- Where are the Kubernetes kubelet logs located?
- Where is the Docker daemon log?
- Where is /var/lib/docker on Mac/OS X

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.