Clean Docker Cache - command not found

How do I setup gitlab shared docker runner to run clear-docker-cache script?

  • gitlab version 13.9

I’ve setup a schedule job to run weekly midnight on Sunday.

Configured my gitlab-ci.yml to run clear-docker-cache script only on scheduled

job:on-schedule:
  only:
    - schedules:
  script:
    - clear-docker-cache

But I’m getting
$ clear-docker-cache
/usr/bin/bash: line 111: clear-docker-cache: command not found.

I’ve even tried:
docker exec gitlab-runner /usr/share/gitlab-runner/clear-docker-cache/clear-docker-cache

I am pulling a custom gradle image from artifactory.

Clearing Docker Cache Doc

This script is available on the Linux server where GitLab Runner package is installed. You need to setup the cron job on the Linux server itself.
As root you can do something like this what will run the cleanup script daily:

cat << _EOF_ > /etc/cron.daily/gitlab_runner_clear_cache.cron
#!/bin/sh
/usr/share/gitlab-runner/clear-docker-cache
_EOF_

chmod +x /etc/cron.daily/gitlab_runner_clear_cache.cron