Docuum performs least recently used (LRU) eviction of Docker images to keep the disk usage below a given threshold.
Docker's built-in docker image prune --filter until=…
command serves a similar purpose. However, the built-in solution isn't ideal since it uses the image creation time, rather than the last usage time, to determine which images to remove. That means it can delete frequently used images, and these may take a long time to build.
Docuum is ideal for use cases such as continuous integration workers, development environments, or any other situation in which Docker images accumulate on disk over time. Docuum works well with Toast or Docker Compose.
Docker doesn't record when an image was last used. To work around this, Docuum listens for notifications via docker events
to learn when images are used. It maintains a small piece of state in a local data directory (see this for details about where this directory is on various platforms). That persisted state allows you to freely restart Docuum (or the whole machine) without losing the image usage timestamp data.
When Docuum first starts and subsequently whenever a new Docker event comes in, LRU eviction is performed until the total disk usage due to Docker images is below the given threshold. This design has two advantages:
Docuum is meant to be started once and run forever, rather than as a cron job. How you do this is up to you. For example, you can run it in a terminal, or you can set it up as a daemon with launchd, systemd, etc.
Running Docuum from the command line is as simple as:
sh
$ docuum --threshold '30 GB'
Here are the supported command-line options:
``` USAGE: docuum
OPTIONS: -h, --help Prints help information
-t, --threshold <THRESHOLD>
Sets the maximum amount of space to be used for Docker images (default: 10 GB)
-v, --version
Prints version information
```
If you are running macOS or a GNU-based Linux on an x86-64 CPU, you can install Docuum with this command:
sh
curl https://raw.githubusercontent.com/stepchowfun/docuum/master/install.sh -LSfs | sh
The same command can be used again to update Docuum to the latest version.
NOTE: Piping curl
to sh
is dangerous since the server might be compromised. If you're concerned about this, you can download and inspect the installation script or choose one of the other installation methods.
The installation script supports the following environment variables:
VERSION=x.y.z
(defaults to the latest version)PREFIX=/path/to/install
(defaults to /usr/local/bin
)For example, the following will install Docuum into the working directory:
sh
curl https://raw.githubusercontent.com/stepchowfun/docuum/master/install.sh -LSfs | PREFIX=. sh
The releases page has precompiled binaries for macOS or Linux systems running on an x86-64 CPU. You can download one of them and place it in a directory listed in your PATH
.
If you have Cargo, you can install Docuum as follows:
sh
cargo install docuum
You can run that command with --force
to update an existing installation.