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
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Hardware-Accelerated OpenGL Rendering in a Linux Container
  • Spinnaker Meets Minikube: Part 1
  • Kubernetes CSI Drivers
  • Kubernetes CNI Drivers

Trending

  • Improving Java Application Reliability with Dynatrace AI Engine
  • Manual Investigation: The Hidden Bottleneck in Incident Response
  • Dear Micromanager: Your Distrust Has a Job; It’s Just Not the One You’re Doing
  • AI Agents in Java: Architecting Intelligent Health Data Systems
  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.9K 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
  • Kubernetes CSI Drivers
  • Kubernetes CNI Drivers

Partner Resources

×

Comments

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

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook