docker imagesList, filter and clean up local images
docker images (docker image ls) lists the images in the local store: name and tag, image ID, size on disk and whether a container uses them. It's how you check what's been built or pulled, spot untagged leftovers, and decide what to remove.
docker images [OPTIONS] [REPOSITORY[:TAG]] (same as docker image ls)You've just built and pulled a few images and want to see what's stored locally and how big it is.
docker imagesList images in the local image store. Same as docker image ls.
The CLI calls GET /images/json. An image is a manifest (a JSON list of layer digests plus a config blob) stored by content: its ID is the sha256 of that config or, with the containerd image store that is the default on new Docker 29 installs, of the manifest or multi-platform index. A tag such as shop-api:1.4.0 is only a name pointing at that digest, so one image can have many tags, and moving a tag to a new build leaves the old image <untagged> (dangling). Layers are shared: ten images built FROM node:22-alpine store its layers once, which is why adding up the SIZE column overstates real disk use. docker system df gives the true total.
-a, --allAlso show intermediate images (legacy builder)-q, --quietOnly image IDs-f dangling=trueOnly untagged images left behind by rebuilds-f reference=PATTERNOnly names matching a glob, like 'shop-api:*'-f before=IMG / since=IMGImages created before or after another image--digestsAdd the content digest (sha256:...) column--format TEMPLATECustom columns, or json--no-truncFull sha256 IDs--treeShow each platform of a multi-platform image (experimental)Adding up the SIZE column to explain disk usageLayers are shared between images, so the same base layers are counted once per image.
docker system df (and docker system df -v for per-image shared vs unique size)docker rmi $(docker images -q) to 'clean up'Tries to delete every image, fails noisily on the ones in use and forces re-pulls of the rest.
docker image prune (dangling only), or docker image prune -a --filter until=168hAssuming nginx:latest on two hosts is the same imageTags are mutable pointers; each host has whatever latest meant when it pulled.
Compare digests (docker images --digests) or deploy by digestTry these on a Linux machine of your own. Each task has a hint and a solution.
List only the IDs of the dangling images on this host.
Write a command that prints each local image as 'name:tag size', one per line, for all shop-api tags.
Explain this line from docker images: 'shop-api:1.4.0 4b1e7d2c9a03 212MB 58.3MB U'. What do the two sizes and the U mean?
docker imagesList, filter and clean up local images
docker images (docker image ls) lists the images in the local store: name and tag, image ID, size on disk and whether a container uses them. It's how you check what's been built or pulled, spot untagged leftovers, and decide what to remove.
docker images [OPTIONS] [REPOSITORY[:TAG]] (same as docker image ls)You've just built and pulled a few images and want to see what's stored locally and how big it is.
docker imagesList images in the local image store. Same as docker image ls.
The CLI calls GET /images/json. An image is a manifest (a JSON list of layer digests plus a config blob) stored by content: its ID is the sha256 of that config or, with the containerd image store that is the default on new Docker 29 installs, of the manifest or multi-platform index. A tag such as shop-api:1.4.0 is only a name pointing at that digest, so one image can have many tags, and moving a tag to a new build leaves the old image <untagged> (dangling). Layers are shared: ten images built FROM node:22-alpine store its layers once, which is why adding up the SIZE column overstates real disk use. docker system df gives the true total.
-a, --allAlso show intermediate images (legacy builder)-q, --quietOnly image IDs-f dangling=trueOnly untagged images left behind by rebuilds-f reference=PATTERNOnly names matching a glob, like 'shop-api:*'-f before=IMG / since=IMGImages created before or after another image--digestsAdd the content digest (sha256:...) column--format TEMPLATECustom columns, or json--no-truncFull sha256 IDs--treeShow each platform of a multi-platform image (experimental)Adding up the SIZE column to explain disk usageLayers are shared between images, so the same base layers are counted once per image.
docker system df (and docker system df -v for per-image shared vs unique size)docker rmi $(docker images -q) to 'clean up'Tries to delete every image, fails noisily on the ones in use and forces re-pulls of the rest.
docker image prune (dangling only), or docker image prune -a --filter until=168hAssuming nginx:latest on two hosts is the same imageTags are mutable pointers; each host has whatever latest meant when it pulled.
Compare digests (docker images --digests) or deploy by digestTry these on a Linux machine of your own. Each task has a hint and a solution.
List only the IDs of the dangling images on this host.
Write a command that prints each local image as 'name:tag size', one per line, for all shop-api tags.
Explain this line from docker images: 'shop-api:1.4.0 4b1e7d2c9a03 212MB 58.3MB U'. What do the two sizes and the U mean?