Update clear docker cache command
Overview
We have clear-docker-cache script which deleted the containers that are marked as cache containers. However with !1989 (merged) we no longer create cache containers and just use docker volumes directly, so this is not longer useful. We also link to this in https://docs.gitlab.com/runner/executors/docker.html#clearing-docker-cache. We should either remove this script or update it to clean up Docker volumes instead.
Proposal
When #25300 (closed) is implemented we should update this script so that we delete the volumes instead of the containers.
A few things to consider:
- Since in https://docs.gitlab.com/runner/executors/docker.html#clearing-docker-cache we suggest users to run this command as cron, it might be the case that the command runs during job execution:
- The removal might fail because the volume is in use, we need to make sure we handle this error properly.
- The volume might be removed between spawn/removing containers during the job, we need to make sure that the Runenr is resilient if the volume gets removed between container spawning.
- Make use of labels so we don't delete any volumes that we don't own/intent to delete