Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
4 views
in DevOps and Agile by (1.5k points)

I am unable to find the containers under the directory:
/var/lib/docker/containers

Can you please tell me the directories and files under /var/lib/docker and also where are the docker images stored on the host machine?

4 Answers

0 votes
by (27.5k points)

This is a solution for Ubuntu users with docker version 1.12.3. 

Use the command, 

$ docker info 

to find the root directory of docker. You will find the docker directory will be given in this line: "Docker Root Dir: /var/lib/docker". The docker images, they are stored inside the docker directory:  /var/lib/docker/ images are stored there. 

If you wish to learn more about Docker, visit Docker tutorial and Docker Training by Intellipaat. 

0 votes
by (33.1k points)

The contents of the /var/lib/docker directory vary depending on the driver Docker is using for storage.

When you will fall back to overlay, overlay2, btrfs, devicemapper or zfs depending on your kernel support. In most places, this will be aufs but the RedHat went with device mapper.

You can manually set the storage driver with the -s or --storage-driver= option to the Docker daemon.

  • /var/lib/docker/{driver-name} will contain the driver specific storage for contents of the images.
  • /var/lib/docker/graph/<id> now only contains metadata about the image, in the json and layersize files.

In the case of aufs:

  • /var/lib/docker/aufs/diff/<id> has the file contents of the images.
  • /var/lib/docker/repositories-aufs is a JSON file containing local image information. This can be viewed with the command docker images.

In the case of device-mapper:

  • /var/lib/docker/devicemapper/devicemapper/data stores the images
  • /var/lib/docker/devicemapper/devicemapper/metadata the metadata

Note these files are thin provisioned "sparse" files so aren't as big as they seem.

Hope this answer helps you!

0 votes
by (37.3k points)

Docker images are stored on your computer in a specific folder. Normally, you may locate them at:

The default website

The route directory {/var/lib/docker/image/overlay2/imagedb/content/sha256} is where Docker keeps the many parts (called "layers") that make up your images.

Driver Regarding Storage: - The exact path may vary depending on Docker's configuration, specifically the storage driver it uses (like {overlay2}, which is the default on most platforms). If Docker is set up to utilize a different storage driver, the path will be modified.

To put things simply, depending on how your system is configured, Docker images are typically stored under ~/var/lib/docker~.

0 votes
by (1.3k points)

Under the /var/lib/docker directory you will normally find the following:

containers, contain container-related information.

images: Download Docker images.

Volumes: Persistent Storage Volumes.

overlay2: Where changes of real image layers are persisted and filesystem changes end up.

Primarily, Docker images are stored in /var/lib/docker/images, but their actual data is mostly in subdirectories such as /var/lib/docker/overlay2. Explore these directories to find container and image data.

Related questions

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...