cki_deployment_clean_docker_images.sh
Remove old docker images on the runners
A list of images to keep is built by image ID, and all other images are
removed. This correctly handles both tagged images and digest-only references
(from SHA-pinned pulls like tag@sha256:...).
The following images are kept:
- all
:latestimages - all
:productionimages - the most recent
mr-*tagged image (configurable viaMR_IMAGE_TAG_COUNT) - the most recent
p-*tagged image (configurable viaPIPELINE_IMAGE_TAG_COUNT) - all
gitlab-runner-helperimages - all images currently in use by running containers
A docker image prune -f runs first to clean up dangling layers before the
keep set is built. All other images (including stale digest-only references)
are then removed by ID.
cki_deployment_clean_docker_images.sh
Environment variables
| Field | Type | Required | Description |
|---|---|---|---|
CKI_DEPLOYMENT_ENVIRONMENT |
string | no | Images are only removed if set to production |
MR_IMAGE_TAG_COUNT |
int | no | Number of newest mr-* tags to keep (default: 1) |
PIPELINE_IMAGE_TAG_COUNT |
int | no | Number of newest p-* tags to keep (default: 1) |