Recent posts
- Rocky Linux 9 and Python SSL
- Fixing a stuck handle on a Samsonite case
- "expected shallow list" error
- ERROR: `fop' is missing on your system.
- pandoc and "resource vanished" error
- AspiegelBot
- Making GPG pinentry work over SSH
- Gmail and "please log in via your web browser" error
Categories
Archive
-
< June 2025 S M T W T F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Syndication
Powered By
Info
Docker cheatsheet
Installation
Use the Docker repositories to obtain the most up-to-date version:
Images
Obtaining images
Executing e.g. docker run centos
will download the specified image.
Listing images
List locally available images:
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE debian 10 5890f8ba95f6 4 weeks ago 114MB debian latest 5890f8ba95f6 4 weeks ago 114MB ubuntu latest f63181f19b2f 6 weeks ago 72.9MB centos 7 8652b9f0cb4c 3 months ago 204MB hello-world latest bf756fb1ae65 14 months ago 13.3kB
List image IDs only (useful for bulk operations, see below):
$ docker images -q ff9735b37ed6 8652b9f0cb4c f1a218c25b76 e76f637b44b7
To filter images by name, use the --filter reference=...
option, e.g.:
$ docker image ls --filter "reference=hello*" REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest bf756fb1ae65 14 months ago 13.3kB
Show image details
Execute docker inspect $image_id
, e.g.:
$ docker inspect 448f22f1582f [ { "Id": "448f22f1582fa9f9cb8810b13d9360f29e55e6f90a6b40ebf93d0b17d5df8b63", "Created": "2021-03-10T07:17:51.119901148Z", "Path": "/sbin/init", "Args": [ "--system" ], ... ]
Removing images
Execute docker rmi $image_id
, e.g.:
$ docker rmi 03b52c782013 Untagged: container_test:0.1 Deleted: sha256:03b52c7820130b5cee698db172030e4bbaa99b600c706d9ef124f131104c81d3
If an image is in use by a container (whether stopped or running), it can only be removed with the --force
option, e.g.:
$ docker image rmi $(docker image ls -q --filter "reference=hello-world") Error response from daemon: conflict: unable to delete bf756fb1ae65 (must be forced) - image is being used by stopped container 3df2b5bf49da $ docker image rmi $(docker image ls -q --filter "reference=hello-world") --force Untagged: hello-world:latest Untagged: hello-world@sha256:31b9c7d48790f0d8c50ab433d9c3b7e17666d6993084c002c2ff1ca09b96391d Deleted: sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b
Containers
A container is an instance of a Docker image which can be executed using the Docker run
command.
List running containers
Running containers and their details can be listed with docker ps
or docker container ls
, e.g.:
$ docker container ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ec40a1bbf8a4 test/redhat:7 "/sbin/init --system" 18 hours ago Up 18 hours 22/tcp, 5432/tcp, 6432/tcp crm17665d cbd1ef55207c test/redhat:7 "/sbin/init --system" 18 hours ago Up 18 hours 22/tcp, 5432/tcp, 6432/tcp crm17665c b58c8054ad1c test/redhat:7 "/sbin/init --system" 18 hours ago Up 18 hours 22/tcp, 5432/tcp, 6432/tcp crm17665b 3d78ef159e6f test/redhat:7 "/sbin/init --system" 18 hours ago Up 18 hours 22/tcp, 5432/tcp, 6432/tcp crm17665a