Docker where images windows

Docker

One question that often arises for both newcomers and seasoned Docker users alike is: «Where are Docker images stored?» Understanding the storage location of Docker images is crucial for managing disk space and optimizing Docker performance.

Whether you’re running Docker on macOS, Windows, or Linux, this blog post will guide you on how to locate Docker images on each platform. Let’s get started!

Where Docker Images are Stored on macOS

The most important point to keep in mind is that Docker doesn’t run natively on macOS. Instead, it operates within a virtual machine using HyperKit. 

For Docker Desktop on macOS, Docker stores Docker images within a disk image file. But what exactly is a disk image file? In simple terms, a disk image file is a single, large file that acts like a virtual «hard drive» for the Docker virtual machine. It contains the entire file system used by Docker, including images, containers, and volumes.

To locate this disk image file, follow the steps below:

#1 Open Docker Desktop

Start Docker Desktop on your Mac if it’s not already running. 

#2 Open settings window

Once Docker Desktop is open, click on the Settings icon (highlighted below) to open the Settings window. 

Docker Desktop home page

Docker Desktop settings page

#3 Navigate to the «Advanced» tab

 In the Settings window, click on the Resources tab, and then click on the Advanced section. 

Docker Desktop settings page

#4 Find disk image location 

Scroll down a bit in the Advanced section until you see Disk image location. Here, Docker Desktop displays the path to the disk image file on your Mac’s file system, as highlighted below:

Docker Desktop settings page

Note that the disk image is managed by the Docker Desktop virtual machine and is not meant to be manually modified or directly accessed. Instead, you should interact with Docker images through Docker CLI commands.

Where Docker Images are Stored on Linux

Unlike macOS, Docker runs natively on Linux. This means that Docker directly interacts with the Linux kernel and filesystem without the need for a virtual machine.

On Linux, all Docker-related data, including images, containers, volumes, and networks, is stored within the /var/lib/docker directory, known as the root directory. The exact directory inside the root directory where images are stored depends on the storage driver being used. For example, if the storage driver is overlay2, the image-related data will be stored within the subdirectory of /var/lib/docker/overlay2.

To find out what storage driver you’re using, you can run the docker info command and look for a field named Storage Driver as shown below:

docker info command output

Note: While it’s useful to know where Docker stores its image-related data, manually altering files or directories within /var/lib/docker is not recommended, as it can disrupt Docker’s operations and lead to data loss.

Where Docker Images are Stored on Windows

For Docker Desktop on Windows configured to use WSL 2 (recommended by Docker), Docker stores Docker images in a disk image. To locate it, follow the steps below:

#1 Open Docker Desktop

Start Docker Desktop on your machine if it’s not already running. 

#2 Open settings window

Once Docker Desktop is open, click on the Settings icon (highlighted below) to open the Settings window. 

Docker Desktop home page

Docker Desktop settings page

#3 Navigate to the «Advanced» tab

 In the Settings window, click on the Resources tab, and then click on the Advanced section. 

Docker Desktop settings page

#4 Find disk image location 

Scroll down a bit in the Advanced section until you see Disk image location. Here, Docker Desktop displays the path to the disk image file on your Windows file system, as shown below:

Docker Desktop settings page

Cleaning up Images Used by Docker

As you use Docker, over time, your system might accumulate many unused and «dangling» images. An unused image is an image not currently used by any container (stopped or running). A dangling image is an image that neither has a repository name nor a tag. It appears in Docker image listings as <none>:<none>. These images can take up significant disk space, leading to inefficiencies and potential storage issues. 

To address this, Docker provides a simple command: docker image prune

To remove all dangling images, run the following command:

docker image prune 

This command will issue a prompt asking whether you want to remove all dangling images. Type y and hit enter to proceed.

To remove unused images, run the following command: 

docker image prune -a

When you run this command, it’ll issue a warning and will prompt you to confirm whether you want to proceed or not. Type y and hit enter to proceed.

You should regularly clean up unused and dangling Docker images to maintain an efficient and clutter-free Docker environment.

Conclusion

Now you know where Docker images are stored on three different platforms: Linux, macOS, and Windows. 

If you’re still unable to find the location where Docker images are stored, which may be due to a specific configuration not covered in this blog post, consider asking questions on platforms such as Stack Overflow and the Docker Community forum.

A deep understanding of Docker images, including knowledge of how to create and manage them, is crucial for mastering Docker. To help you with this, check out the blog posts below:

  • How to Build a Docker Image With Dockerfile From Scratch
  • How to Create Docker Image From a Container?
  • How to Remove Unused and Dangling Docker Images?
  • Why and How to Tag a Docker Image?
  • What Are Docker Image Layers and How Do They Work?
  • How to Run a Docker Image as a Container?

Interested in learning more about Docker? Check out the following courses from KodeKloud:

  • Docker for the Absolute Beginner: This course will help you understand Docker using lectures and demos. You’ll get a hands-on learning experience and coding exercises that will validate your Docker skills.  Additionally, assignments will challenge you to apply your skills in real-life scenarios.
  • Docker Certified Associate Exam Course: This course covers all the required topics from the Docker Certified Associate Exam curriculum. The course offers several opportunities for practice and self-assessment. There are hundreds of research questions in multiple-choice format, practice tests at the end of each section, and multiple mock exams that closely resemble the actual exam pattern.

Docker has become an essential tool in the world of software development and deployment, enabling developers to package applications into containers for consistency across various environments. However, understanding how Docker works requires knowing where Docker stores its images and containers on your system. In this article, we’ll break down the storage of Docker images, making it easy to understand where these files are stored and how to manage them.

#Docker images overview

A Docker image is a lightweight, standalone, executable package that includes everything needed to run software, service, runtime, libraries, and settings. Images are fundamental in Docker because they provide a repeatable and consistent environment for your applications.

#Images and containers

Docker images are different from containers. A Docker image is essentially a blueprint that defines how a container should be created, while a container is the runtime instance of that image.

Now, let’s explore the storage locations of Docker images.

Ready to supercharge your Docker infrastructure? Scale effortlessly and enjoy flexible storage with Cherry Servers bare metal or virtual servers. Eliminate infrastructure headaches with free 24/7 technical support, pay-as-you-go pricing, and global availability.

#Default location on Linux

When you install Docker on Linux, the default location for storing Docker images is under /var/lib/docker. This directory holds not only your images but also your containers, volumes, and other data Docker uses to function.

Within this directory, you’ll find subdirectories like overlay2 (or sometimes aufs, depending on your Docker setup). This is where Docker stores image layers, and each layer is a read-only file system.

Here’s an example of how you can view the images Docker is storing:

#List docker images

Use the following command to list all Docker images currently stored on your system:

#View storage backend

The storage backend is important for understanding the layout of the Docker image files. Common backend drivers are overlay2, zfs, and btrfs. Run the following command to see which storage driver Docker is using:

$ docker info | grep Storage
Storage Driver: btrfs

Docker organizes images in layers, where each layer represents a different file system change (like installing a package or adding a file). These layers are stacked on top of each other using the storage driver to form a complete image.

Also read: How to Update a Docker Image

#Default location on windows and macOS

On Windows and macOS, Docker runs inside a virtual machine due to the way Docker utilizes Linux features. This means the image storage is a bit different from Linux, but the general concept remains the same.

For Windows, Docker Desktop stores images in the following path:

C:\ProgramData\DockerDesktop\

For macOS, Docker Desktop stores images within the internal VM under the directory:

/Users/<your-username>/Library/Containers/com.docker.docker/Data/vms/

In both cases, the actual image files reside within the Docker virtual machine, and you can interact with them via Docker’s command-line interface.

#Managing docker storage

As you work with Docker, your system can accumulate a large number of images, containers, volumes, and other data. This can lead to disk space issues over time. Managing storage effectively is critical to keeping your development environment healthy.

Here are a few common practices for managing Docker storage:

#Clean up unused images

To remove unused or untagged (dangling) images, you can run:

#Remove all stopped containers

If you want to remove containers that are no longer running, use:

Also check: How to Deploy a Docker Container on Kubernetes

#Check disk usage

Docker has a built-in command to check how much disk space is being used by images, containers, and volumes. Use this command:

This will give you a breakdown of the storage consumption and help you decide if it’s time to prune unused images or containers.

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          1         1         13.26kB   0B (0%)
Containers      1         0         0B        0B
Local Volumes   0         0         0B        0B
Build Cache     0         0         0B        0B

Also read: How to Build a Docker Image

#Change docker’s storage location

If your system’s default storage location runs low on space, you can configure Docker to use a different directory. To do this, you’ll need to modify the docker.service file and change the --data-root parameter. Here’s a basic guide on how to do this on Linux:

1. Stop Docker:

sudo systemctl stop docker

2. Create or Modify the Docker service file located at /etc/docker/daemon.json and add the new storage location:

{
  "data-root": "/new/path/to/docker"
}

3. Restart Docker:

sudo systemctl start docker

By default, Docker uses the system’s main disk for storage, but by changing the data-root parameter, you can configure it to use an external disk or any other location that better suits your needs.

Also read: How to run Docker on bare metal cloud

#Conclusion

Understanding where Docker stores its images is an important part of mastering containerized applications. On Linux, this data is typically stored in /var/lib/docker, while on Windows and macOS, Docker uses a virtual machine to manage storage. Keeping track of your image storage and cleaning up unused images can help you optimize disk usage and maintain a smooth-running development environment.

By regularly managing Docker’s storage through pruning and moving the storage location when necessary, you can prevent your system from becoming overwhelmed with unused containers and images. Docker’s flexibility allows you to adjust these settings according to your project’s needs, ensuring your workflow remains efficient.

Containers stop working. Disk space vanishes mysteriously. Your build pipeline breaks during deployment. These common Docker problems often trace back to a single question: where are Docker images stored and how does this storage system work?

Docker’s image storage isn’t just a technical detail—it’s fundamental to successfully running containerized applications. The container filesystem works differently across operating systems, with unique storage paths for Linux, macOS, and Windows environments. Whether you’re managing Docker storage on a single development machine or orchestrating container image distribution across production clusters, understanding the Docker daemon data directory structure is essential.

This guide explores exactly where Docker stores your images, from the image layers storage in /var/lib/docker/overlay2 on Linux to Docker Desktop’s VM-based storage on macOS and Windows. You’ll learn how Docker’s storage drivers impact image location, discover effective methods for managing Docker disk space, and master techniques for optimizing your Docker storage configuration.

By the end, you’ll understand:

  • Default storage locations across all major operating systems
  • How storage drivers affect where and how images are stored
  • Practical commands for monitoring and managing image storage
  • Advanced strategies for production environments
  • Troubleshooting techniques for common storage issues

Docker images are stored in several places, depending on your setup:

  1. Local Docker Engine: When you pull or build images, they’re stored locally in the Docker daemon’s storage directory:
    • On Linux: /var/lib/docker/
    • On macOS: In a VM managed by Docker Desktop, accessed via the Docker Desktop app
    • On Windows: C:\ProgramData\Docker\windowsfilter (Windows containers) or in a VM (Linux containers)
  2. Registry: Docker images are typically distributed through registries:
    • Docker Hub (public registry)
    • Private registries (Harbor, Nexus, AWS ECR, Google GCR, Azure ACR)
    • Self-hosted registries
  3. Image Layers: Docker uses a layered filesystem where each image consists of multiple read-only layers, with containers adding a writable layer on top.

You can view locally stored images using:

docker images

Or get more detailed information:

docker system df -v

To see where exactly Docker stores data on your system:

docker info | grep "Docker Root Dir"

Is there a specific aspect of Docker image storage you’d like me to explain in more detail?

Default Storage Locations

Linux Storage Paths

Docker storage architecture organizes container images in a logical way. On Linux systems, Docker stores all its data in /var/lib/docker. This Docker daemon data directory handles everything related to your containers and images.

The /var/lib/docker directory contains several subdirectories:

  • containers: Stores container-specific files
  • image: Holds image metadata and references
  • overlay2: Where image layers actually live
  • volumes: Manages persistent data
  • network: Contains network configuration

The most important folder for image storage is /var/lib/docker/overlay2. This is where the container filesystem layers reside. Each image consists of multiple content addressable storage layers stacked together.

When you run docker pull, image blobs download to this location. The overlay2 storage driver (the default on most systems) handles how these layers work together.

Image metadata lives in separate locations from the actual binary data. This Docker library location helps the container runtime storage system track what you have locally.

macOS Storage Locations

Docker Desktop for Mac works differently. It runs inside a lightweight VM since Docker needs Linux kernel features.

The Docker.raw file contains everything – all your images, containers, and volumes. This virtual disk image grows dynamically as you add more content.

Finding this file might surprise you. It’s typically located at:

~/Library/Containers/com.docker.docker/Data/vms/0/Docker.raw

Accessing the VM storage from macOS requires special steps. The Docker storage configuration keeps this abstracted for most users.

Docker Desktop versions have changed paths over time. Newer versions might use different locations, so check documentation for your specific version.

Windows Storage Paths

Windows offers two Docker backend options: WSL2 and Hyper-V.

With the WSL2 backend (now the default), Docker images live inside the Linux subsystem. The exact path depends on your WSL2 distribution, but typically follows Linux conventions.

For legacy Hyper-V backends, Docker uses a dedicated VM. Container image files store in a virtual hard drive at:

C:\Users\[YourUsername]\AppData\Local\Docker\wsl\data\ext4.vhdx

Docker Desktop data location can be customized. File access between Windows and Docker environment happens through mapped drives.

Storage Drivers and Their Impact

Available Storage Drivers

Docker supports multiple storage drivers, each using different techniques for container image hosting:

  1. Overlay2: The default and recommended storage driver offers the best balance of performance and compatibility. It uses the overlay filesystem to stack image layers.
  2. AUFS: An older storage engine still used on some systems. It was the original Docker storage driver but has been largely replaced.
  3. Btrfs: Leverages the Btrfs filesystem’s snapshot features. This storage backend works well when your host uses Btrfs natively.
  4. ZFS: Similar to Btrfs, it uses ZFS filesystem capabilities for image layer caching and management.
  5. Device Mapper: Uses direct device management. Popular in enterprise environments and Red Hat-based systems.

Your choice affects Docker image management significantly. Container image distribution also changes based on your selection.

How Storage Drivers Affect Image Location

Storage structure differences between drivers can be dramatic. Each driver organizes data differently:

  • Overlay2 creates directories for each layer
  • Device Mapper uses block devices
  • ZFS and Btrfs use filesystem-specific features

Performance variations exist too. Overlay2 generally offers the best read/write speeds for most workloads. Device Mapper thin provisioning might show slower container startup times.

Compatibility considerations matter when choosing a driver. Some only work on specific Linux kernels or filesystems. Docker storage monitoring becomes essential when optimizing for your environment.

When should you choose specific drivers? Consider:

  • Use Overlay2 for most standard installations
  • Choose Btrfs or ZFS if your host already uses these filesystems
  • Device Mapper works better in certain enterprise environments
  • AUFS only when other options aren’t available

The image layer deduplication strategy differs between drivers. This affects how efficiently Docker storage handles duplicate content across images.

Managing Docker disk space requires understanding how your specific driver stores and references image data. Docker storage troubleshooting starts with knowing which driver you’re using and its unique characteristics.

Managing Docker Image Storage

Checking Docker Disk Usage

Docker’s content addressable storage system can consume significant disk space. Track usage with simple commands.

Run docker system df to get a quick overview of space used by images, containers, and volumes. This reveals your Docker storage architecture at a glance.

$ docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              12                  8                   3.85GB              1.2GB (31%)
Containers          8                   5                   34.2MB              12.1MB (35%)
Local Volumes       3                   3                   328B                0B (0%)
Build Cache         0                   0                   0B                  0B

Find large images with docker images and sort by size. This shows which container image files consume the most space.

Need deeper analysis? Try docker system df -v for verbose output showing detailed space usage. Container image metadata reveals which layers are shared or unique.

Monitoring storage growth helps manage Docker storage limits before problems occur.

Cleaning Up Unused Images

Docker image cleanup is essential for managing disk space. Several image management commands help with this.

Remove specific images with docker rmi:

docker rmi nginx:1.19

For bulk cleanup, use docker image prune to remove dangling images (those not associated with containers). Add -a to remove all unused images:

docker image prune -a

System-wide cleanup with docker system prune removes multiple unused resources:

docker system prune --all --volumes

Implement automated cleanup strategies using cron jobs or CI/CD pipelines. Docker storage monitoring scripts can trigger cleanup when thresholds are reached.

Moving Docker’s Storage Location

Need more space? Configure daemon.json to relocate the Docker library location:

  1. Edit or create /etc/docker/daemon.json:
    {
      "data-root": "/path/to/new/docker/data"
    }
    
  2. Restart Docker daemon:
    sudo systemctl restart docker
    

Relocating to external drives solves space constraints. The migration process for existing images requires careful planning to avoid data loss.

After changing Docker storage configuration, verify the new path with:

docker info | grep "Docker Root Dir"

Docker image migration should show all your previous content in the new location.

Registry and Remote Storage

Docker Hub and Other Registries

Container image repositories like Docker Hub provide remote storage for images. These remote registries function as centralized Docker image hosting services.

When you run docker pull nginx, the Docker daemon contacts Docker Hub (the default registry), downloads the image layers, and stores them locally. The Docker pull command’s mechanics affect how images are cached locally.

Registry caching behavior can be optimized. Docker stores layer blobs efficiently, downloading only what’s missing locally thanks to the image manifest location checks.

Private registry configurations offer alternatives to Docker Hub:

  • Amazon ECR
  • Google Container Registry
  • Azure Container Registry
  • GitHub Container Registry
  • Quay.io
  • Harbor Registry

Each registry implements the Docker Registry API and OCI Format standards for container image distribution.

Container Image Distribution Models

Teams face tradeoffs between local and remote storage. Local storage offers speed but consumes disk space. Remote registries provide centralized management but require network bandwidth.

Many organizations adopt hybrid approaches. Common patterns include:

  • Local caching registries
  • Registry mirrors
  • Multi-stage builds to reduce image size
  • Optimizing Docker storage with smaller base images

Image distribution in CI/CD pipelines often involves pushing to a private registry after successful builds. Jenkins, GitHub Actions, and other tools support the Docker push command as part of automation.

Network vs. storage optimization depends on your priorities. In bandwidth-constrained environments, focus on layer deduplication and compression. For storage-constrained systems, aggressive image cleanup and retention policies work best.

Docker image versioning through tags helps manage which versions to keep or remove. Proper image tag strategies prevent accidental deletion of critical images while enabling Docker storage troubleshooting and optimization.

Docker Storage in Production Environments

Multi-Host Considerations

Production deployments rarely rely on single hosts. Docker storage architecture becomes more complex when scaling across multiple servers.

Shared storage solutions help maintain consistency across nodes. NFS volumes, cloud storage, or specialized container storage interfaces provide access to the same Docker image layers from multiple hosts. This reduces unnecessary duplication of container image files.

Image distribution strategies matter in multi-host environments. Options include:

  • Pull-through cache registries
  • Local registry mirrors
  • Registry per cluster region
  • Pre-pulling critical images

Storage redundancy prevents downtime from disk failures. Many teams implement RAID configurations for the Docker daemon data directory or use cloud-provider redundant storage.

Disaster recovery approaches should include Docker image backup strategies. Regularly push critical custom images to remote registries or implement filesystem-level backups of the Docker storage location.

Orchestration Platforms

Kubernetes handles image storage differently than standalone Docker. The container runtime interface connects Kubernetes to containerd or other container runtimes, which manage local image storage.

Each Kubernetes node maintains its own local cache of container images in paths similar to Docker’s. When pods schedule to nodes, kubelet ensures required images exist locally.

Swarm mode storage follows Docker’s standard patterns but adds distribution awareness. Images pull only when needed on specific nodes.

Image caching in node clusters requires thoughtful planning. Consider:

  • Cache warming for critical images
  • Image garbage collection policies
  • Storage driver consistency across nodes
  • Node disk capacity planning

Container image metadata stays synchronized through the orchestration platform’s control plane. This ensures consistent deployment regardless of which node runs your workload.

The Docker registry API enables orchestrators to efficiently manage image distribution. Kubernetes, for example, implements sophisticated image pull policies and secrets for registry authentication.

Troubleshooting Storage Issues

Common Storage Problems

Storage issues frequently cause Docker headaches. Four problems appear most often:

“No space left on device” errors occur when the filesystem hosting /var/lib/docker fills up. This stops all operations requiring disk writes, including creating new containers or downloading images.

Corrupted image layers happen from interrupted downloads, disk errors, or Docker daemon crashes. Symptoms include containers failing to start with cryptic errors about missing files.

Storage driver conflicts emerge after system updates or changing drivers without proper migration. Container image hosting depends on consistent storage drivers.

Permission issues prevent Docker from writing to storage locations. This especially affects custom Docker storage configuration or mounted volumes.

Each issue connects to how Docker storage drivers interact with your host system.

Diagnostic Techniques

Start Docker storage troubleshooting by checking logs:

journalctl -u docker.service

Look for errors related to storage drivers, permission denials, or space issues.

Verify image integrity with:

docker image inspect <image-id>

This shows complete image layer information, helping identify corrupted layers in the container image repository.

Analyze storage driver performance with:

docker info

Check the storage driver section for warnings or errors. Performance issues often relate to misconfigured or inappropriate storage drivers for your workload.

Docker storage monitoring should include:

  • Regular disk usage checks
  • I/O performance monitoring
  • Image layer growth tracking
  • Registry connection reliability

When severe corruption occurs, recovery options include:

  1. Removing and re-pulling affected images
  2. Rebuilding local images from Dockerfiles
  3. Restoring from backups
  4. In extreme cases, migrating to a new Docker storage backend

Docker image inspection tools help diagnose which specific layers cause problems. Container image security scanning might detect corrupted layers before they cause operational issues.

Docker storage limits apply to various components:

  • Maximum layers per image (127)
  • Maximum image size (platform dependent)
  • Registry-specific push limits
  • Docker Hub rate limits

Understanding these constraints helps troubleshoot unexpected failures in your Docker storage engine.

Best Practices for Docker Image Storage

Image Optimization Techniques

Docker image optimization directly impacts storage efficiency. Multi-stage builds dramatically reduce image size by separating build-time dependencies from runtime needs.

Here’s a simple example:

# Build stage
FROM node:14 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# Production stage
FROM nginx:alpine
COPY --from=builder /app/build /usr/share/nginx/html

This approach eliminates unnecessary build tools from the final image layer, significantly reducing Docker storage requirements.

Using smaller base images makes a massive difference. Alpine-based images often measure 5-10MB compared to hundreds of megabytes for full distributions. The container filesystem becomes much leaner, improving Docker image distribution speed.

Layer optimization strategies require understanding how the Docker storage driver handles changes:

  1. Order Dockerfile commands from least to most frequently changed
  2. Combine related commands in single RUN statements
  3. Remove temporary files in the same layer they’re created
  4. Use .dockerignore to prevent unnecessary files from entering the image

The overlay2 storage driver handles these optimizations particularly well, making image layer caching more efficient.

Image vulnerability scanning should be part of your workflow. Tools integrated with your registry can flag security issues while also helping identify bloated images.

Storage Planning and Maintenance

Capacity planning prevents Docker storage troubleshooting emergencies. Analyze current usage patterns and project growth:

# Get baseline measurements
docker system df -v > storage-baseline.txt

Monitor this weekly to understand growth trends in your container image repository.

Set up Docker storage monitoring with alerts before space becomes critical:

#!/bin/bash
USAGE=$(df /var/lib/docker | tail -1 | awk '{print $5}' | sed 's/%//')
if [ $USAGE -gt 85 ]; then
  echo "Docker storage at $USAGE%" | mail -s "Docker Storage Alert" admin@example.com
fi

Implement retention policies for images using tags and automated cleanup:

# Keep only last 3 versions of each image
docker images | grep myapp | sort -V | head -n -3 | awk '{print $3}' | xargs docker rmi

Docker image versioning through appropriate tagging makes this maintenance simpler.

Backup strategies for critical images should include:

  1. Regular pushes to multiple Docker Hub or private registry locations
  2. Using docker save to export images to tar files
  3. Version control for Dockerfiles and build contexts
  4. Documentation of image dependencies and configurations

Container image security measures should cover the entire lifecycle from build to storage to deployment.

Image distribution in CI/CD pipelines should include automated storage cleanup to prevent accumulation of outdated images. This Docker storage best practice prevents uncontrolled growth of your local Docker library location.

When optimizing Docker storage configuration, balance these factors:

  • Performance needs
  • Storage redundancy requirements
  • Image layer deduplication benefits
  • Registry caching behavior

The Docker storage backend you choose significantly impacts how these optimizations work. Most environments benefit from the default overlay2 driver, but specialized workloads might need different options.

Regularly review Docker image hosting options as your environment grows. Moving from Docker Hub to self-hosted Docker images or enterprise registry solutions might make sense at certain scale points.

Remember that Docker storage architecture decisions have long-term implications. Well-planned container image storage makes scaling, maintenance, and disaster recovery much simpler.

FAQ on Where Are Docker Images Stored

Where exactly are Docker images stored on Linux?

Docker stores images in the /var/lib/docker directory on Linux systems. This Docker daemon data directory contains multiple subdirectories including overlay2 (or your specific storage driver name), where the actual image layers reside. Each layer in the container filesystem has its own directory with a unique hash identifier. The Docker storage architecture separates metadata from the binary data, with manifest files stored separately from the actual content. You can verify your storage location by running docker info | grep "Docker Root Dir".

How can I change where Docker stores images?

Modify the Docker storage configuration by editing the daemon.json file. Create or edit /etc/docker/daemon.json and add:

{
  "data-root": "/path/to/new/location"
}

After changing the Docker library location, restart the Docker daemon with systemctl restart docker or equivalent for your system. This relocates the entire Docker storage backend, including all container image files. Verify the change took effect with docker info. Some users move Docker to larger drives when managing Docker disk space becomes challenging.

Where are Docker images stored on Windows?

Windows Docker image storage depends on your configuration. With WSL2 backend (default in newer Docker Desktop versions), images store inside the Linux subsystem, typically in a .vhdx file at %USERPROFILE%\AppData\Local\Docker\wsl\data\ext4.vhdx.

For Hyper-V backend, Docker Desktop stores images in a VM’s virtual hard drive. The container image repository lives inside this VM, not directly on the Windows filesystem. Access Docker settings to change storage locations or manage Docker storage limits.

How do I find and delete unused Docker images?

Use these commands for Docker image management:

# List all images
docker images

# Check space usage
docker system df

# Remove specific image
docker rmi image_name:tag

# Remove dangling images
docker image prune

# Remove all unused images
docker image prune -a

# Complete cleanup
docker system prune --all --volumes

Implementing Docker image cleanup regularly prevents storage issues. Image layer caching means some layers may be shared between images, so the Docker storage engine only removes layers not referenced by any remaining images.

Do I need to worry about Docker Registry storage separately?

Yes. Docker Hub and private registries like GitHub Container Registry, Amazon ECR, or Google Container Registry have their own storage systems. When using docker pull, images download from these registries to local storage. The Docker registry API handles this transfer efficiently.

Self-hosted Docker images in private registries require their own storage planning. Registry caching behavior affects network usage, while image distribution systems need proper monitoring. Consider implementing image vulnerability scanning and Docker storage monitoring for both local and registry storage.

Docker’s content addressable storage uses a layered approach. The OCI Format defines how image layers stack to create a complete container filesystem. When multiple containers use the same base image, they share those common image layers, saving significant space.

Each layer contains only the differences from previous layers. The overlay2 storage driver (the default) efficiently manages these layers, creating thin, stackable filesystems. This image layer deduplication is key to Docker’s storage efficiency. Container image hosting takes advantage of this to minimize redundant storage.

Can I move Docker images between machines without a registry?

Yes, use docker save and docker load:

# Export image to file
docker save my_image:tag > my_image.tar

# Transfer file to other machine

# Import image from file
docker load < my_image.tar

This creates a portable archive containing all image layers. It’s useful for Docker image migration or container image sharing in air-gapped environments. Remember that Docker image versioning through tags helps track these images properly.

Why is my Docker storage location running out of space?

Common causes include:

  1. Unused containers with volumes
  2. Dangling and unused images
  3. Build cache accumulation
  4. Large image layers from inefficient Dockerfiles

Use docker system df -v for detailed Docker storage troubleshooting. The container runtime storage grows over time without maintenance. Implement regular cleanup with automated scripts and optimize Dockerfiles using multi-stage builds to reduce image size.

How do Kubernetes and Docker Swarm handle image storage?

Orchestration platforms add complexity to Docker storage architecture. Kubernetes stores images on each node, pulling from registries as needed. The container image distribution happens independently on each node.

Docker Swarm uses the standard Docker storage engine but coordinates image pulls across the swarm. Both require careful image management strategies, especially for container image caching and storage monitoring. The Docker storage backend configuration should be consistent across all nodes in your cluster.

What happens to my images if I reinstall Docker?

Reinstalling the Docker daemon typically doesn’t affect images if you don’t remove the Docker storage location. However, backup critical custom images by:

  1. Pushing to Docker Hub or private registry
  2. Using docker save to export important images
  3. Documenting your image build process

If you delete /var/lib/docker (or equivalent on your OS), you’ll lose all local images and containers. The Docker storage engine creates new storage structures upon reinstallation, but won’t recover previous data without proper backups.

Conclusion

Understanding where are Docker images stored forms the foundation of effective container management. The Docker storage engine operates differently across platforms, but the principles remain consistent: layered filesystems, content-addressable storage, and driver-specific implementations. Whether you’re working with the container image repository in Linux’s /var/lib/docker, navigating Docker Desktop’s VM on macOS, or managing WSL2 storage on Windows, knowledge of the underlying architecture empowers you to make informed decisions.

Container image hosting extends beyond local storage to registry systems and orchestration platforms. Docker image versioning, storage driver selection, and image layer deduplication all play crucial roles in optimizing your container workflow. As containerization continues to evolve, managing Docker storage limits and implementing proper image cleanup strategies becomes increasingly important for both development and production environments.

Remember that Docker’s strength lies in its flexibility. You can customize the Docker library location, choose appropriate storage backends, and implement registry caching behavior that suits your specific needs. By applying the best practices outlined in this guide, you’ll maintain efficient container image distribution while avoiding common storage pitfalls.

If you liked this article about where are Docker images stored, you should check out this article about Kubernetes vs Docker.

There are also similar articles discussing what is Docker hub, what is a Docker container, what is a Docker image, and what is Docker compose.

And let’s not forget about articles on where are Docker volumes stored, how to use Docker, how to install Docker, and how to start Docker daemon.

  • Author
  • Recent Posts

Bogdan is a seasoned web designer and tech strategist, with a keen eye on emerging industry trends.

With over a decade in the tech field, Bogdan blends technical expertise with insights on business innovation in technology.

A regular contributor to TMS Outsource’s blog, where you’ll find sharp analyses on software development, tech business strategies, and global tech dynamics.

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.

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:

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
python              latest              9038c75f5336        12 hours ago        933MB
nginx               latest              5ad3bd0e67a9        2 days ago          127MB
nginx                             5a3221f0137b        5 months ago        126MB
ubuntu              latest              a2a15febcdf3        5 months ago        64.2MB

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:

# docker info

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:

$ docker info | grep "Docker Root Dir"
Docker Root Dir: /var/lib/docker

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:

drwx------.  2 root root   23 Jan 16  2019 builder
drwx------.  4 root root   87 Jan 16  2019 buildkit
drwx------.  3 root root   19 Jan 16  2019 containerd
drwx------.  3 root root   77 Aug 27 11:33 containers
drwx------.  5 root root   50 Aug 20 14:03 devicemapper
drwx------.  4 root root   35 Aug 20 13:36 image
drwxr-x---.  3 root root   18 Jan 16  2019 network
drwx------.  4 root root   30 Jan 16  2019 plugins
drwx------.  2 root root    6 Jan 24 11:12 runtimes
drwx------.  2 root root    6 Jan 16  2019 swarm
drwx------.  2 root root    6 Jan 24 11:12 tmp
drwx------.  2 root root    6 Jan 16  2019 trust
drwx------.  2 root root   30 Aug 20 13:36 vfs
drwx------.  2 root root   24 Jan 16  2019 volumes

Looking inside the images directory on my system, there are two subdirectories:

drwx------.  5 root root   77 Aug 27 11:21 devicemapper
drwx------.  5 root root   77 Aug 20 13:36 vfs

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:

$ docker info | grep "Storage Driver"

Looking inside my /var/lib/docker/image/devicemapper directory I can see:

drwx------. 4 root root   56 Aug 20 14:03 distribution
drwx------. 4 root root   35 Jan 16  2019 imagedb
drwx------. 5 root root   42 Aug 20 14:03 layerdb
-rw-------. 1 root root 1.5K Jan 24 11:39 repositories.json

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.

du --summarize -h
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:

$ du -h --summarize
1.5G .

Of the subdirectories here, the data one stores the images and the metadata directory stores the image metadata.

/var/lib/docker/devicemapper/devicemapper/data - stores the images
/var/lib/docker/devicemapper/devicemapper/metadata - contains the 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:\ProgramData\DockerDesktop

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.

Learning Docker?

If you are starting out, then I highly recommend this book.

Are you thirsty for more?

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.

Are you trying to figure out where Docker stores its images on your Windows 10 machine? Don’t worry, you’re not alone! Docker images can take up a substantial amount of space on your system, and knowing where they are stored is the first step in managing them effectively. In this article, I’ll walk you through how to find the Docker image storage location on Windows 10.

Before we dive into the steps, it’s important to understand what we’re looking for. Docker stores its images and containers in a directory called the Docker desktop-data. Finding this directory will help you manage your Docker images more efficiently.

Step 1: Open the Docker settings

Open the Docker desktop application and navigate to the settings menu.

The Docker settings can usually be found in the system tray at the bottom right of your Windows 10 taskbar. Clicking on the Docker icon will give you a list of options, and from there you can click on “Settings” to open the Docker Desktop settings window.

Step 2: Click on “Resources”

In the settings menu, click on the “Resources” tab.

The “Resources” tab is where you can manage the system resources that Docker is allowed to use. This includes memory, CPUs, and disk image location.

Step 3: Look for “Disk image location”

Under the “Advanced” section of the “Resources” tab, find the “Disk image location” setting.

Here, you’ll see the current location where Docker is storing its images and containers. By default, this is usually set to the C: drive on Windows 10 systems, but it can be changed to another location if needed.

After completing these steps, you will have located the directory where Docker stores its images and containers. You can now manage your Docker images more effectively, whether that’s by cleaning up unused images to free up space or moving them to another location.

Tips for Locating Docker Image Storage

  • Docker images can consume a lot of disk space, so it’s good practice to regularly check and clean up unused images.
  • If you’re running low on space on your C: drive, consider changing the Docker image storage location to another drive with more space.
  • Regularly backing up Docker images can prevent data loss in case of system failures.
  • Utilizing Docker volumes can help with persisting data without taking up space in the image storage location.
  • Keep Docker and the Docker Desktop application updated to ensure you have access to the latest features and bug fixes.

Frequently Asked Questions

What is a Docker image?

A Docker image is a lightweight, standalone, executable package that includes everything needed to run a piece of software, including the code, runtime, system tools, libraries, and settings.

Can I move the Docker image storage location?

Yes, you can move the Docker image storage location to another drive or folder by changing the “Disk image location” setting in the Docker Desktop application.

How can I free up space used by Docker images?

You can free up space by removing unused Docker images, containers, and volumes using Docker commands like docker image prune or docker system prune.

Is there a way to limit how much space Docker can use?

Yes, you can limit the disk space Docker uses by setting a maximum size for the disk image in the Docker Desktop settings.

Do I need to restart Docker after changing the image storage location?

Yes, after changing the image storage location, you will need to restart Docker for the changes to take effect.

Summary

  1. Open Docker settings
  2. Click on “Resources”
  3. Find “Disk image location”

Conclusion

Finding the Docker image storage location on Windows 10 is a simple process that can save you headaches when managing your system’s resources. By following the steps outlined in this article, you can easily locate the Docker desktop-data directory and take control of your image storage. Remember, keeping your Docker images organized and freeing up space when necessary are crucial for maintaining a healthy system. Additionally, consider moving your Docker image storage location if you’re running out of space on your primary drive. Docker is a powerful tool for developers, and understanding how to manage its storage is an important part of maximizing its benefits. So go ahead, take these steps, and streamline your Docker experience on Windows 10!

Matt Jacobs has been working as an IT consultant for small businesses since receiving his Master’s degree in 2003. While he still does some consulting work, his primary focus now is on creating technology support content for SupportYourTech.com.

His work can be found on many websites and focuses on topics such as Microsoft Office, Apple devices, Android devices, Photoshop, and more.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Мастер очистки для windows xp
  • Как очистить журнал защиты в защитнике windows 10
  • Как перезапустить службу центра обновления windows
  • Windows server 2019 rdp сервер
  • Мтс коннект соединение разорвано windows 10