If you deal with Docker on a daily basis, you need to know a few commands. If you’re like me and forget these things, here’s a cheat sheet to help ;)
Summary
Listing
Images on your machine
Lists all the images on your machine, including the dangling ones
|
Running containers
|
All containers
And their info
|
Only the IDs of all containers
|
Removing
A container that was stopped
|
All containers that were stopped
|
An image from the system
If the image isn’t in use, you can remove it using the command below along with the image ID
|
All images from the system
Removes ALL Docker images that aren’t in use from your machine. Use with care!
It’ll show an error if any image is in use.
|
All images from the system
Removes ALL Docker images that aren’t in use from your machine. Use with care!
It’ll ignore images in use.
|

Killing
One or more containers
Just pass a list of IDs to kill more than one container
|
Some useful options to know
-a
Most, if not all, Docker commands and subcommands have an -a option which comes from all.
–rm
Same thing happens with the --rm option. When used, it indicates that the container should be removed after its execution.
-q
Most, if not all, Docker commands and subcommands have a -q option that lists only the IDs.