Docker TOTD - container id to aufs diff mount id

Estimated reading time: 2 mins

Table of contents

Ever asked yourself where to find the information what aufs diff folder maps to a running container? It’s pretty simple if you just poke around a little bit in the /var/lib/docker folder. But lets start at the beginning.

In the default Docker engine configuration, aufs is the storage driver which is used for images and container diffs. You can read on about the aufs driver at the official Docker aufs documentation here.

To sum it up, the base entity of every running container is the underlying image. This insight will direct us to the /var/lib/docker/image folder, more exactly to the /var/lib/docker/image/aufs/layerdb/mounts/ folder.

Insight the mounts folder, you can find directories named along your running containers. inside this containers, you will find a file called mount-id. This file contains the information about the aufs id which will help you to find the correct aufs diff directory of the running container in the /var/lib/docker/aufs/diff/ folder.

Here is a full example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
[10:03 /var/lib/docker/image/aufs/layerdb/mounts]# ls
1f500742f31bc22dab85b83805ae88afae23a713cc4c2857fb624eedfcef3c7e

[10:03 /var/lib/docker/image/aufs/layerdb/mounts]# cd 1f500742f31bc22dab85b83805ae88afae23a713cc4c2857fb624eedfcef3c7e/

[10:03 /var/lib/docker/image/aufs/layerdb/mounts/1f500742f31bc22dab85b83805ae88afae23a713cc4c2857fb624eedfcef3c7e]# ls
init-id  mount-id  parent

[10:03 /var/lib/docker/image/aufs/layerdb/mounts/1f500742f31bc22dab85b83805ae88afae23a713cc4c2857fb624eedfcef3c7e]# cat mount-id 
9307f7abdcdca4657002a5084bae91745ecd5b5e6ac11448b00185dce016a54c

[10:03 /var/lib/docker/image/aufs/layerdb/mounts/1f500742f31bc22dab85b83805ae88afae23a713cc4c2857fb624eedfcef3c7e]# cd /var/lib/docker/aufs/diff/9307f7abdcdca4657002a5084bae91745ecd5b5e6ac11448b00185dce016a54c/

[10:28 /var/lib/docker/aufs/diff/9307f7abdcdca4657002a5084bae91745ecd5b5e6ac11448b00185dce016a54c]# ls
adasd  root  run  var

[10:28 /var/lib/docker/aufs/diff/9307f7abdcdca4657002a5084bae91745ecd5b5e6ac11448b00185dce016a54c]#

Happy hacking - M

(Featured image taken from the official Docker aufs documentation here)

Posted on: Fri, 10 Nov 2017 10:37:41 +0100 by Mario Kleinsasser
  • General
  • Docker
  • Doing Linux since 2000 and containers since 2009. Like to hack new and interesting stuff. Containers, Python, DevOps, automation and so on. Interested in science and I like to read (if I found the time). My motto is "𝗜𝗺𝗮𝗴𝗶𝗻𝗮𝘁𝗶𝗼𝗻 𝗶𝘀 𝗺𝗼𝗿𝗲 𝗶𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁 𝘁𝗵𝗮𝗻 𝗸𝗻𝗼𝘄𝗹𝗲𝗱𝗴𝗲. [Einstein]". Interesting contacts are always welcome - nice to meet you out there - if you like, do not hesitate and contact me!