Docker System Prune
To release unused Docker containers, networks and images, it is possible to remove them completely with a simple command. Removing the unused resources frees up hard disk space.
Prerequisites
- GitLab Runner
- SSH access
Execute System Prune
To perform a Docker System Prune on the GitLab Runner, establish an SSH connection with your privileged SSH user. The Docker System Prune can then be executed with the following command:
sudo docker system prune [OPTIONS]
Available options
Option | Description |
---|---|
-a , -all | Removes all unused containers, networks and images |
-f , --force | No reconfirmation required |
--volumes | Remove anonymous and unused volumes |
If the SSH command cannot be executed by your SSH user, please contact our support so that your user can be assigned the necessary rights. (Managed)
Set up cronjob
If you want to set up the Docker System Prune as a cronjob that is executed automatically at the desired time, you can set up the cronjob in our customer center. Please use our help center article under Cronjobs.
Alternatively, you can use crontab -e
to create a cronjob on the GitLab Runner itself. You can use our standard configuration for this or alternatively edit it as you wish.
Standard configuration:
0 0 * * * sudo docker system prune -a -f
┬ ┬ ┬ ┬ ┬
│ │ │ │ │
│ │ │ │ └──── Day of the week (0-7, Sunday is 0 or 7)
│ │ │ └────── Month (1-12)
│ │ └──────── Day (1-31)
│ └────────── Hour (0-23)
└──────────── Minute (0-59)
You can then save the file and the cron job will be executed every night at 00:00 (UTC).
Check hard disk space
If the Prune system does not free up enough memory, this is due to used data and files that are necessary for the operation of the Runner. If this is the case, we recommend enlarging the hard disk. See also: Enlarge hard disk