6.6 Avoid image sprawl




Keep the set of the images that you actually need and establish a workflow to remove old or
stale images from the host. Additionally, use features such as pull-by-digest to get specific
images from the registry. Additionally, you can follow below set of steps to find out unused images on the system and
delete them.

Step 1 Make a list of all image IDs that are currently instantiated by executing below
docker ps -q | xargs docker inspect --format '{{ .Id }}- Image={{ .Image }}'
Step 2- List all the images present on the system by executing below command-docker images
Step 3- Compare the list of image IDs populated from Step 1 and Step 2 and find out images
that are currently not being instantiated.
Step 4- Decide if you want to keep the images that are not currently in use. If not delete
them by executing below command-docker rmi $IMAGE_ID


Default Value-Images and layered filesystems remain accessible on the host until the administrator
removes all tags that refer to those images or layers.

See Also


Item Details


References: 800-53|CM-7b.

Plugin: Unix

Control ID: 683075be5b3ab422f6843064ae74a2d2384900a968987ff3192356bba9e0c3b1