How to find the docker container size

Problem

The storage space of your docker Host runs low or empty. You need to know the size of your docker container to find out which container has grown too much.

Solution

Run docker ps --size in a console and you will find output like this:

Docker Container Size

Look at the 813 kB (virtual 52.7 MB) and 19.7 MB (virtual 570 MB).

Ignore the virtual values, relevant for the used storage space is the value before the parentheses. So the first container uses 813 kB Storage Space and the second one 19.7 MB.

That´s not too bad.

Explanation

Docker Container are stateless. This means that when you restart them, all the resources they had used will be freed.

But e.g. logs that are not exposed could grow a lot and increase the storage space usage for this container.

It is a best practice to not have the logs inside the container, but you sometimes they might be in a sub folder and it was forgotten to mount a volume to remove the logs from the container.

So with this little statement you can find the responsible containers and act accordingly.

Let me know when this helped you.

Best,

Frank

Sources:

https://www.digitalocean.com/community/questions/how-to-check-the-disk-usage-of-all-running-docker-containers

Leave a Reply