Skip to content

Improve docker cleanup script to also include old builds and images

Silvester Wainaina requested to merge clear-docker-cache-build-images into master

What does this MR do?

The current script is not sufficient as it also leaves old images, builds that also contribute to the unused space.

Why was this MR needed?

I propose to improve the script to include clearing the old build and images as part of the clean up process.

What's the best way to test this MR?

  1. Register a docker runner and choose docker as your runner executor. Add the tag in your pipeline job
  2. Once you run the pipeline it will create the docker images and volumes
  3. Use the following command to check the volumes
#Check images
docker images -q --filter "dangling=true"

#Check volumes
docker volume ls -qf dangling=true --filter label=com.gitlab.gitlab-runner.type=cache
  1. Execute the clear docker script to delete the dangling images and volumes.
  2. Repeat step 3 to confirm that the images and volumes have been deleted

What are the relevant issue numbers?

This has been inspired by a couple of tickets e.g. #155060 (internal) that have had the same issue but the current script was not sufficient

Documentation changes: !2586 (merged)

closes #25458 (closed)

Edited by Steve Xuereb

Merge request reports