Docker Basic Commands Cheatsheet

Docker commands cheatsheet for common use and cleanup
Tags : docker

Containers manage
List
$ docker ps

List all
$ docker ps -a

Stop running containers
$ docker stop $(docker ps -q)

Remove
$ docker rm #IMG_ID_OR_NAME#

Remove container and its volume
$ docker rm -v #IMG_ID_OR_NAME#

Remove all
$ docker rm $(docker ps -aq)
Images manage
List images
$ docker images

Remove
$ docker rmi #IMG_ID#

Remove "dangling" images, marked <none>
$ docker rmi -f $(docker images -f dangling=true -q)
Volumes manage
List
$ docker volume ls

List "dangling"
$ docker volume ls -f dangling=true

Remove
$ docker volume rm #VOLUME_NAME#

Prune
$ docker volume prune
Cleanup images, containers, volumes, networks
$ docker system prune

// Also cleanup stopped containers and unused images
$ docker system prune -a