Unused Docker images can silently consume significant disk space across your cluster. Over time, this can lead to bloated storage and degraded performance. Robin simplifies the process of identifying and removing these unused images across hosts in your cluster. This blog post walks you through how to prune unused images manually and how to automate the process using scheduled jobs.
๐ง Command: robin host pruneimage
This command allows you to prune unused Docker images from one or more hosts in your Robin cluster. These are images not currently used by any running containers.
๐ Syntax
๐น Parameters
hostnames: Comma-separated list of host FQDNs (e.g.,vnode36.robinsystems.com)--skip-images-file <path>: Path to a file listing images to exclude from pruning. Format:<image>:<tag>per line.--all: Prune unused images from all hosts in the cluster.
๐งน 4.12.1 Pruning Images
To remove unused images from a specific host, use:
✅ Output
Job: 226 Name: HostPruneImagesMulti State: PROCESSED Error: 0
Job: 226 Name: HostPruneImagesMulti State: COMPLETED Error: 0
This output confirms that the pruning job was successfully processed and completed without errors.
⏰ 4.12.2 Enabling Pruning Schedule
Robin allows you to automate image pruning using a CRON schedule. This mimics garbage collection and keeps your system clean without manual intervention.
๐น Step 1: Enable the schedule
# robin config update server enableimageprune_schedule true
Output:
The 'server' attribute 'enable_image_prune_schedule' has been updated
๐น Step 2: Set the CRON schedule
This CRON string schedules the pruning job to run daily at 2:00 AM.
# robin config update server image_prune_cron "0 2 * * *" The 'server' attribute 'image_prune_cron' has been updated
Output:
The 'server' attribute 'image_prune_cron' has been updated
๐ซ 4.12.3 Disabling Pruning Schedule
To stop the automatic pruning job, simply disable the schedule:
# robin config update server enableimageprune_schedule false
Output:
The 'server' attribute 'enable_image_prune_schedule' has been updated
๐ Summary
| Task | Command | Description |
|---|---|---|
| Manual prune | robin host pruneimage <host> | Removes unused images from specified host |
| Skip specific images | --skip-images-file <path> | Prevents listed images from being pruned |
| Prune all hosts | --all | Targets all hosts in the cluster |
| Enable schedule | robin config update server enable_image_prune_schedule true | Turns on scheduled pruning |
| Set schedule | robin config update server image_prune_cron "<cron>" | Defines when pruning should occur |
| Disable schedule | robin config update server enable_image_prune_schedule false | Turns off scheduled pruning |
๐ก Pro Tip
Use the --skip-images-file option to protect critical images from being accidentally removed. This is especially useful in production environments where certain base images are reused frequently.
No comments:
Post a Comment