Blog
WebsiteLoginFree Trial
  • 🏠PagerTree Blog
  • 📣AT&T Email to Text Ends June 17, 2025: Switch to PagerTree Notifications
  • 📣Meet the PagerTree CLI: Your New On-Call Sidekick!
  • 📣OpsGenie Shutdown Announced: Why PagerTree Is Your Best Alternative in 2025
  • 💎Getting Started With Ruby on Rails in 2024 - The Complete Development Environment Guide
  • 📣WhatsApp Notifications
  • 🧠Site Reliability Engineer (SRE) Interview Questions
  • 👑What is System Monitoring?
  • 👑Top 5 Best PagerDuty Alternatives in 2024
  • 🔡Understanding Linux File System: A Comprehensive Guide to Common Directories
  • 🔡Ping Command: A Comprehensive Guide to Network Connectivity Tests
  • 📜Fly.io migrate-to-v2 Postgres stuck in read-only mode
  • 💎Multi-Tenant SSO using Devise
  • ✨PromQL Cheat Sheet: A Quick Guide to Prometheus Query Language
  • 🔡PowerShell Cheat Sheet: Essential Commands for Efficient Scripting
  • 📣Critical Alerts for iOS and iPhone
  • 📣PagerTree 4.0 is finally here!
  • 💎Ruby on Rails Polymorphic Select Dropdown
  • 🧠SRE Metrics: Availability
  • 🚨Incident Response Alert Routing
  • 💎Ruby on Rails Development Setup for Beginners
  • ✨Jekyll site to AWS S3 using GitHub Actions
  • 💎Migrate attr_encrypted to Rails 7 Active Record encrypts
  • 💎Ruby on Rails Cheat Sheet
  • 📣PagerTree Forms Integration
  • 📣Public Team Calendars
  • 📣Slack, Mattermost, Microsoft Teams, and Google Chat
  • 📣On-call Schedule Rotations
  • 📣Maintenance Windows
  • ✨Docker Commands Cheat Sheet
  • 🪄Slack Channel Stakeholder Notifications
  • 📣PagerTree Live Call Routing
  • 🧠The Science of On-Call
  • ✨serverless
    • 🧠What is Serverless?
    • 🧠Serverless Scales
    • 🧠Serverless Costs
    • ✨Serverless Tools and Best Practices
  • ✨Prometheus Monitoring Tutorial
Powered by GitBook
On this page
  • Check Running Containers
  • SSH Into Container
  • Restart A Container
  • Check CPU and Memory Usage
  • Check Disk Space Usage
  • Prune Images and Volumes
  • Docker Links You Might Find Useful
  • Images
  • Blog Articles
  • PagerTree Cheat Sheets
  • Cheat Sheets (PDFs)

Was this helpful?

Docker Commands Cheat Sheet

Docker Commands Cheat Sheet- A quick reference guide to Docker CLI commands used on a daily basis: usage, examples, snippets and links.

PreviousMaintenance WindowsNextSlack Channel Stakeholder Notifications

Last updated 1 year ago

Was this helpful?

In this article I will highlight the 6 key docker commands I use on a daily basis while using Docker in the real world.

By no means is this an extensive list of docker commands. I kept it short on purpose so you could use it as a quick reference guide. I’ve also omitted the topic of building images and the commands that are associated with that.

At the bottom of the page, I’ll also put some good links to other Docker resources I like or frequently use as well as other PagerTree cheat sheet documents. For a full crash course, check out our Learn Docker Series!

Command
Short Description

docker ps

List running containers

docker exec -it <container name> /bin/sh

SSH into container

docker restart <container name>

Restart a container

docker stats

Show running container stats

docker system df

Check docker daemon disk space usage

docker system prune -af

Remove images, networks, containers, and volumes

Check Running Containers

  • Command: docker ps

  • Description: Show running containers.

  • Official Docs: https://docs.docker.com/engine/reference/commandline/ps/

Normally I will use this command just as often as I use ls command on a *NIX terminal. It’s especially useful when you first SSH to a machine to check what’s running. It’s also useful during the development and configuration process since you’ll likely have containers stopping/starting/crashing.

SSH Into Container

  • Command: docker exec -it <container name> /bin/sh

  • Description: SSH into a container.

  • Official Docs: https://docs.docker.com/engine/reference/commandline/exec/

This is probably my 2nd most popular command. Normally I am using this while trying to debug a container and need to shell into the container. Just note the -i flag means interactive and -t means TTY (aka a teletype terminal).

Also, you can use any command instead of /bin/sh; I only put that here because I frequently am SSHing into an alpine image which doesn’t support bash.

Restart A Container

  • Command: docker restart <container name>

  • Description: Restart a container.

  • Official Docs: https://docs.docker.com/engine/reference/commandline/restart/

I debated putting this command in here, since I don’t use it all that often, but it’s a nice to have. Great example of when to use this - you change your prometheus configuration and need it to pick up the changes in your config file. You might also use this when resizing a volume.

Other commands you might use often, but I didn’t think were so worthy of their own section are docker start (see docs) and docker stop (see docs). You’ll use these commands normally when setting up or testing images and you’ll likely use a lot of flags. I didn’t think they were so applicable because you should honestly be using docker compose or some other orchestration system (like Amazon ECS or Kubernetes) to launch your containers.

Check CPU and Memory Usage

  • Command: docker stats

  • Description: Display a live stream of running containers usage statistics.

  • Official Docs: https://docs.docker.com/engine/reference/commandline/stats/

I’m normally using this command when I am trying to figure out optimal soft/hard limits for containers. You might also use this if you are debugging which container is using most of your host’s resources.

Check Disk Space Usage

  • Command: docker system df

  • Description: Display information about disk space being used by your containers.

  • Official Docs: https://docs.docker.com/engine/reference/commandline/system_df/

This one doesn’t come up to often, but it has, especially when you are building lots of images on a box or you are storing lots of data (like prometheus). If you are, you might consider setting up a cron job to prune your images and volumes on a recurring basis.

Prune Images and Volumes

  • Command: docker system prune -af

  • Description: Remove all unused images (dangling and unreferenced), containers, networks, and volumes.

  • Official Docs: https://docs.docker.com/engine/reference/commandline/system_prune/

You’ll probably only use this command on a Docker build machine or on your dev box, nevertheless take note, cause you are likely to use it.

Also, just like mentioned above, if this is a build box consider setting up a cron job to prune your images. If you’re a cron syntax noob like me, you might find crontab.guru of use in understanding the syntax and shortcuts for popular time intervals.

Docker Links You Might Find Useful

Images

  • VPN - Run an IPsec VPN server. Super useful if you work from cafes like Starbucks.

  • Prometheus + Grafana Setup - Out of the box Prometheus and Grafana setup. We actually use a fork of this for monitoring the PagerTree platform.

  • Alpine Image - Slim OS image for Node.js apps in production.

  • GitLab Runner - A GitLab Runner inside a docker container. We use this at PagerTree to build our images.

Blog Articles

  • Learn Docker Series - A quick and concise overview of all the peices of Docker you need to know.

  • Docker Crash Course - If you’re new to Docker this is a great crash course. Starts from installing Docker all the way to docker compose. It can be a lot to take in so you might have to read it a couple times.

  • Deployment Automation with GitLab Runner - Super helpful writeup on setting up the GitLab Runner for your own CI/CD pipeline. Used this tutorial extensively when setting up PagerTree’s CI/CD.

PagerTree Cheat Sheets

  • PromQL Cheat Sheet

  • Ruby On Rails Cheat Sheet

  • PowerShell Cheat Sheet

Cheat Sheets (PDFs)

You can download this entire blog article with the "Export as PDF" link in the top right of this page (you might have to be on the desktop version. Additionally, below I've provided some PDFs from the web I have found useful.

docker ps Example Output
docker exec -it Example Output
docker stats Example Output
docker system df Example Output
docker system prune -af Example Output
crontab -l Example Output
✨
Docker command cheat sheet crontab
Docker Stats Example Output
Docker Cheat sheet exec
Docker PS Example Output
Docker command cheat sheet System Off
67KB
docker-commands-cheat-sheet.pdf
pdf
pagertree.com docker commands cheat sheet
545KB
docker_official_cheat_sheet.pdf
pdf
Official Docker Cheat Sheet
344KB
red_hat_developer_docker_cheat_sheet.pdf
pdf
Red Hat Developer Cheat Sheet
307KB
cheat-sheet-v2.pdf
pdf
Docker Cheat Sheet V3 by @dockerlux
See download link below for PDF
Docker Command Cheat Sheet
Page cover image
Docker command cheat sheet image prune