docker images stored location

Where the Docker images are stored locally?

This tutorial shows how to check where the docker images are stored locally depending on the docker storage driver and based on your operating system.

Where the docker images are stored ?

Open the terminal and run the following command $ docker info

$ docker info
Client:
 Debug Mode: false

Server:
 -------------
 -------------
 Server Version: 18.09.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 4.19.79+
 Operating System: Debian GNU/Linux 9 (stretch) (containerized)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 1.949GiB
 Name: cs-6000-devshell-vm-ea287578-f8bb-440d-9448-b06672f20f20
 ID: MFUJ:HB6E:HIKX:Q65J:LUS4:VZWL:6EID:LLCC:R2YW:P2UG:4B6S:TSY5
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  https://asia-mirror.gcr.io/
 Live Restore Enabled: false
 Product License: Community Engine

From the above response you know that docker root directory is /var/lib/docker  (Docker Root Dir: /var/lib/docker). The contents of the docker root directory vary depending on the docker storage driver, it can be aufs or overlay, overlay2, btrfs, devicemapper etc. In our case it is overlay2 (Storage Driver: overlay2).

$ cd /var/lib/docker
$ ls
builder  buildkit  containerd  containers  image  network  overlay2  plugins  runtimes  swarm  tmp  trust  volumes

Note, debian by default it will be overlay2 and in case of RedHats it will be devicemapper. And in some other operating systems or some other distribution of linux it would be different.

The location of docker images  in our case identified using the following linux commands as shown below

(/var/lib/docker/image/overlay2)

$ ls
builder  buildkit  containerd  containers  image  network  overlay2  plugins  runtimes  swarm  tmp  trust  volumes
$ cd image
$ ls
overlay2
$ cd overlay2
$ ls
distribution  imagedb  layerdb  repositories.json

repositories.json

{"Repositories":{"alpine":{"alpine:latest":"sha256:e7d92cdc71feacf90708cb59182d0d92d29e8e95d75ca6a99776a",
"[email protected]:ddba4d27a7ffc3f86dd6c2f920f252a1f23a8e76e1297bfa1bc0c45":"sha256:e7d92cdc71feacf907b59182d0df1b911f8a29e8e95d75ca6a99776a"},
"hello-docker":{"hello-docker:v1":"sha256:22f5373692976d1a96ab2602117acdb9b2419ecb0010758af8b1893bfbfc"}}}

Note, repositories.json is a JSON file which contains local image information and the same information can also be view using the following command $ docker images

/var/lib/docker/image/overlay2 $ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-docker        v1                  22f537369297        5 minutes ago       5.59MB
alpine              latest              e7d92cdc71fe        12 days ago         5.59MB

Further Learning

References

Leave a Reply

avatar
  Subscribe  
Notify of