DockerCheatSheet - albertmon/smarthome GitHub Wiki

UNDER CONSTRUCTION!!

DockerCheatSheet

Explanation of terms

Image

An image can be seen as an isolated filesystem. It contains everything needed to run an application - all dependencies, configuration, scripts, binaries, etc.
The image also contains other configuration for the container, such as environment variables, a default command to run, and other metadata.

Container

A container is a runtime instance of a docker image.

A Docker container consists of

  • A Docker image
  • An execution environment
  • A standard set of instructions

The concept is borrowed from Shipping Containers, which define a standard to ship goods globally. Docker defines a standard to ship software.


Tasks

Cleanup containers

To cleanup your containers, first check which containers you have:

docker ps -a

This will list all running and not running containers.
To remove a container, look in the NAMES column and use that name in the command:

docker rm name

Cleanup images

When you have old images (you may have downloaded from the Docker Hub) you might want to remove them.
Execute the command:

docker images

This will list all images. You can remove ONLY images with no containers (running or not running), so first cleanup your containers
To remove an image, look _image_id_in the IMAGE ID column for the image_id and use that name in the command:

docker rmi image_id

Some useful commands

Description: Remove all stopped containers

docker container prune