Docker CLI Cheat Sheet
Published: 9th of December 2020
Intro
Docker is a fantastic tool. In this post I am documenting common/useful commands for working with the Docker CLI.
Containers
Show all local running containers.
cmd
docker container ls
Show all local containers.
cmd
docker container ls -a
Stop all local running containers.
cmd
docker container stop $(docker container ps -a -q)
Stop all local stopped containers.
cmd
docker container rm $(docker container ps -a -q)
Images
Show all local images.
cmd
docker images ls
Remove dangling image layers.
cmd
docker images ls --quiet --filter "dangling=true"
Delete all local images.
cmd
docker rmi $(docker images -a -q)
Docker Hub
Pull an image from Docker Hub with the latest tag.
cmd
docker pull ruby
Pull a specific version of an image.
cmd
docker pull debian:10.7-slim
docker pull ruby:2.7.2-slim-buster
docker pull postgres:13.1
Links
https://www.digitalocean.com/community/tutorials/how-to-remove-docker-images-containers-and-volumes