I can see that Docker takes 12GB of my filesystem:
2.7G /var/lib/docker/vfs/dir
2.7G /var/lib/docker/vfs
2.8G /var/lib/docker/devicemapper/mnt
6.3G /var/lib/docker/devicemapper/devicemapper
9.1G /var/lib/docker/devicemapper
12G /var/lib/docker
But, how do I know how this is distributed over the containers?
I tried to attach to the containers by running (the new v1.3 command)
docker exec -it <container_name> bash
and then running 'df -h' to analyze the disk usage. It seems to be working, but not with containers that use 'volumes-from'.
For example, I use a data-only container for MongoDB, called 'mongo-data'.
When I run docker run -it --volumes-from mongo-data busybox
, and then df -h
inside the container, It says that the filesystem mounted on /data/db
(my 'mongo-data' data-only container) uses 11.3G, but when I do du -h /data/db
, it says that it uses only 2.1G.
So, how do I analyze a container/volume disk usage? Or, in my case, how do I find out the 'mongo-data' container size?
To see the file size of your containers, you can use the
--size
argument ofdocker ps
:Keep in mind that
docker ps --size
may be an expensive command, taking more than a few minutes to complete. The same applies to container list API requests withsize=1
. It's better not to run it too often.Take a look at alternatives we compiled, including the
du -hs
option for the docker persistent volume directory.I use
docker stats $(docker ps --format={{.Names}}) --no-stream
to get :(this answer is not useful, but leaving it here since some of the comments may be)
docker images
will show the 'virtual size', i.e. how much in total including all the lower layers. So some double-counting if you have containers that share the same base image.documentation