Docker TOTD - container id to aufs diff mount id
Estimated reading time: 2 mins
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:
[10:03 /var/lib/docker/image/aufs/layerdb/mounts]# ls
[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
[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
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
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). Einstein said "Imagination is more important than knowledge. For knowledge is limited." - I say "The distance between faith and knowledge is infinite. (c) by me". Interesting contacts are always welcome - nice to meet you out there - if you like, do not hesitate and contact me!
www.n0r1sk.com 2009 - 2020
All content, if not otherwise mentioned is CC-BY 4.0