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 stats --no-stream gives you one snapshot instead of a live screen

Docker
~/tips/docker-stats-no-stream

docker stats --no-stream

Prints one table with CPU and memory per container, then gives you your prompt back.

Plain docker stats takes over your terminal. When I only want to know who is eating the CPU, I want one answer and my prompt back.

docker stats --no-stream

The docs describe the flag as disabling the live stream and pulling only the first result. You get one table with CPU, memory and network use per running container and then you are done. Add -a to include stopped containers.

The --format option takes a template, so you can ask for just what you need, for example docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}". Because it exits, it also works in a script or a cron job.

The caveat: the first sample of a container that just started can look odd, so run it again after a few seconds before you decide a container is the culprit.

Animation: typing docker stats --no-stream in a terminal
One snapshot, then your prompt is back

Further reading: Docker docs: docker stats, On this site: docker inspect tells you if a container is healthy, not just running, On this site: docker logs –since 10m -f shows only what just happened

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