Where are Docker images stored on the host machine?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Docker is a popular platform for developing, shipping, and running applications inside containers. Containers bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. One of the fundamental components of Docker is the Docker image, which is a lightweight, standalone, executable package that includes everything needed to run a piece of software, including the code, a runtime, libraries, environment variables, and configuration files.
Understanding Docker Images
Docker images are immutable files that are essentially snapshots of a container. They act as a template from which Docker containers are run. An image is built from a series of layers that add changes to an initial base image. These changes (layers) include the addition, modification, or removal of files and directories.
Storage Locations on the Host Machine
The location where Docker images are stored on the host machine depends on the underlying operating system and the Docker configuration, specifically the Docker daemon’s storage driver. Different drivers manage and store images and containers in varying formats.
Linux Systems
On Linux, Docker stores its data by default in /var/lib/docker/. However, this location can change if Docker is configured differently (via docker daemon configurations). Here are where specific types of information are stored:
- Image Layers: Stored as subdirectories under
/var/lib/docker/overlay2/(assuming the default Overlay2 filesystem). Each layer corresponds to a Docker image layer. - Container Layers: Changes made to a running container based on an image are stored here. These are typically writable layers over the immutable image layers.
Windows Systems
For Docker Desktop on Windows, the default storage location is more complex since Docker runs within a Hyper-V VM:
- Docker Images and Containers: Located within the Linux VM, typically under the path
C:\ProgramData\DockerDesktop. The actual image files are stored within a virtual disk image, which gets mounted by the Hyper-V VM.
Storage Drivers
Docker supports multiple storage drivers, which affect how images and containers are stored. Common drivers include:
- aufs
- devicemapper
- btrfs
- zfs
- overlay
- overlay2 (recommended due to improved performance and disk space utilization compared to overlay)
Each driver handles the storage of images and layers in its unique way, impacting performance and efficiency.
Configuring Custom Storage Locations
Administrators can change the location where Docker stores its images and containers by configuring the Docker daemon settings. This involves editing the Docker configuration file (usually located at /etc/docker/daemon.json) and setting the data-root to a new directory path:
After making this change, the Docker service will need to be restarted for the changes to take effect.
Summary of Key Points
| Aspect | Details |
| Default Path on Linux | /var/lib/docker/ |
| Default Path on Windows | C:\ProgramData\DockerDesktop within a Hyper-V VM |
| Storage Drivers | Includes overlay2, aufs, devicemapper, btrfs, zfs, overlay |
| Changing Storage Location | Modify data-root in /etc/docker/daemon.json |
| Image and Container Storage | Managed by Docker’s storage drivers; stored in separate directories per driver |
By understanding where and how Docker images are stored on the host machine, users and administrators can better manage storage resources, performance, and ensure proper data backup and recovery procedures are in place.

