Last Updated: February 25, 2016
· yitsushi

Get size of running docker containers


First of all you need to locate your docker's directory. On Linux maybe you can find it in /var/lib/docker.

Now we can discover the content of this magic, but our primary goal is now the aufs directory and exactly the diff subdirectory.

Here we can find diffs so, it's a commit or that you can commit. So if you start a container it has an ID and an initial image (under diff) and an own diff directory.

If you sum of that two directory you get the site of your container (maybe?). Of course if your have commits on it that it will be a little bit complicated but most of the time I run an image and when I don't need I delete it. If I want to modify the image that I make a new initial image.

If your have volumes than you can find them under /var/lib/docker/volumes for instance. So if you run a simple container than all of your files will be stored in their own diff.


DIFFPATH="/var/lib/docker/aufs/diff"; \
(for d in `docker ps -q`; do du -s ${DIFFPATH}/${d}*; done;) | \
sed -e 's/-init//g' | \
awk '{ sum[$2] += $1 }; END { for (path in sum) { print sum[path]/1024"M", path } }'



121.125M /var/lib/docker/aufs/diff/5dd90664d4021be8949fcf0b0ad7770216cf667a8f80b1336f7ae23a11aaaa2d
658.043M /var/lib/docker/aufs/diff/afc7176ce9aea02839b380823d4c7fec7f74569172f113e5ce43c168b026d7ae