BLOG

Docker Cheat Sheet

Christian Fröhlingsdorf
June 2, 2021
Table of Contents:

In this article, we will showcase the six most practical Docker commands that one continually needs in daily Docker dealings.

Please note that this is, of course, not a complete list of all possible commands but serves as a short reference list of the most important ones.

6 Practical Docker Commands

Befehl Beschreibung Offizielle Doku
docker ps Alle laufenden Container auflisten Dokumentation
docker stats Stats der laufenden Container anzeigen Dokumentation
docker exec -it <container name> /bin/sh SSH in Container Dokumentation
docker system prune -af Alle Images, Container und Netzwerke löschen Dokumentation
docker kill <container name> Einen Container (hart) stoppen Dokumentation
docker logs <container name> Logs eines Containers anzeigen Dokumentation

List All Running Containers

With docker ps, you can list all running containers and get an overview of the names and IDs. From here, you can execute additional commands like logs, stop, or kill.

Display Stats of the Running Containers

docker stats list all running containers in a manner similar to ps and displays their current resource consumption.

Open SSH in a Container

To open shell session in a running Docker container, you can use the exec command: docker exec -it <container name> /bin/sh. However, ensure that the necessary binaries are present as many bootstrap base container images are trimmed to an absolute minimum.

Delete All Images, Containers, and Networks

A command to clean up everything on the local development machine is docker system prune -af. Naturally, this command should be used with caution.

Stopping a Container Hard

The stop command sends a SIGTERM. If this is not sufficient or not fast enough, a container can be abruptly stopped with docker kill via SIGKILL.

Display Logs of a Container

A command that every Docker user encounters multiple times daily is docker logs <container name> which output the log lines of the container. Another commonly used option is docker logs --follow <container name> to keep the log stream open.

Additional Information

A more extensive official cheat sheet for Docker commands can also be found at the Official Docker Cheat Sheet.

Other blog posts you might like:

Ready to elevate your incident management?
Start for free
Our Cookie Policy
We use cookies to improve your experience, analyze site traffic and for marketing. Learn more in our Privacy Policy.
Open Preferences
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.