DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Hardware-Accelerated OpenGL Rendering in a Linux Container
  • Spinnaker Meets Minikube: Part 1
  • Getting Started With Windows Containers
  • Setting Apache Nifi on Docker Containers

Trending

  • Operational Principles, Architecture, Benefits, and Limitations of Artificial Intelligence Large Language Models
  • How To Build Resilient Microservices Using Circuit Breakers and Retries: A Developer’s Guide To Surviving
  • A Developer's Guide to Mastering Agentic AI: From Theory to Practice
  • Hyperparameter Tuning: An Overview and a Real-World Example
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Where Are Docker Images Stored on the Host Machine?

Where Are Docker Images Stored on the Host Machine?

The Docker Images and other objects are stored inside the docker directory in the local machine depending upon the default storage driver being used by the machine

By 
Raunak Jain user avatar
Raunak Jain
·
Jul. 28, 21 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
10.5K Views

Join the DZone community and get the full member experience.

Join For Free

When we create Docker objects such as images, containers, volumes, etc., all these objects are stored inside a directory in our local machine. By default, all the Docker objects are stored in the following directory.

 /var/lib/docker/<storage-driver>

Moreover, the contents stored inside the /var/lib/docker path depend on the storage driver that you are using as well. Let’s first understand the docker storage drivers in short.

Docker Storage Drivers

In an ideal case, very little amount of data gets written onto the writable layer of a Docker container. We use volumes in Docker to write such data but there are some workloads that require us to be able to use the container’s writable layer to write data. This is exactly where storage drivers in Docker come in.

Docker uses a pluggable architecture to support various different storage drivers. It totally depends upon these storage drivers that how the Docker images and containers are managed and stored in our Docker host.

The different types of storage drivers supported by Docker are - overlay2, aufs, devicemapper, btrfs, zfs, vfs. The current default Docker Storage driver is overlay2.

To check the default storage driver, you can use the following command.

$ docker info

You can set the storage driver in two different ways.

You can either use the -s or --storage-driver option along with the Docker run command or you can edit the /etc/docker/daemon.json file and include the following lines.

{
"storage-driver":"aufs"
}

Now that we have understood the basics of storage drivers in Docker, let’s see the different behaviors of different drivers when it comes to storing Docker objects in local machines.

Storage of Docker Images and Other Objects

The driver-specific storage for Docker image contents will be in the path - 

/var/lib/docker/{driver-name}

The metadata about the images is located in the JSON and layersize files in the following directory.

/var/lib/docker/graph/<id>

In the above paths, the driver-name is the default storage driver used by Docker in your machine and the id refers to the image ID.

If your host machine uses aufs storage driver for Docker, then you can look for image file contents in the following directory:

/var/lib/docker/aufs/diff/<id>

The directory mentioned below contains the local image information in a JSON file. This information can be retrieved using the Docker images command in the command line.

/var/lib/docker/repositories-aufs

In the case of the device-mapper storage driver, the system stores the image information in the following directory:

/var/lib/docker/devicemapper/devicemapper/data

The metadata related to the images can be found in the following way: 

/var/lib/docker/devicemapper/devicemapper/metadata

It’s important to note that these files are not that big as they might seem to be because of the fact that they are thin provisioned sparse files.

If you are using Docker inside Mac through a virtual machine, then you can find all your container and image information in the following directory:

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

On the new Windows 10 which uses hyper-v, you can find the data in the Docker virtual hard disk in the following path:

C:\Users\Public\Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx

Wrapping Up

To sum up, the Docker storage drivers play a huge role in deciding the storage location of your metadata as well as all other information related to all the Docker objects including images, containers, volumes, etc.

However, the base directory path is /var/lib/docker and the subsequent directories depend upon the type of storage driver. Moreover, the location varies with respect to the type of operating systems as well. 

Docker (software) Machine Host (Unix) Driver (software) Directory

Published at DZone with permission of Raunak Jain. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Hardware-Accelerated OpenGL Rendering in a Linux Container
  • Spinnaker Meets Minikube: Part 1
  • Getting Started With Windows Containers
  • Setting Apache Nifi on Docker Containers

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!