brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker container ls --size shows how much each container has written

Docker
~/tips/tip-docker-container-ls-size

docker container ls -s

Adds a size column that shows how much data each container wrote on top of its image.

A Docker host that slowly fills up has a culprit, and often it is one container writing into its own filesystem instead of a volume.

docker container ls -s
docker ps -a -s

The -s flag adds a SIZE column with two numbers, like 12MB (virtual 187MB). The first is the data in the writable layer of the container, so what it changed or created. The second, virtual size, is that plus the read-only image data underneath.

A big first number is the thing to chase. It usually means logs, temp files or a database writing to the container layer. A container with 0B there is not growing at all.

Sizes of virtual data overlap, because containers from the same image share the same read-only layers. Do not add up the second numbers to get the disk use. For the real total use docker system df.

The caveat is that the command only lists running containers unless you add -a, and calculating sizes can take a while on a host with many containers. For a single container docker inspect --size reports SizeRw and SizeRootFs in its output.

Further reading: docker container ls reference

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link