Docuum performs least recently used (LRU) eviction of Docker images. 🗑️
Docuum performs least recently used (LRU) eviction of Docker images to keep the disk usage below a given threshold.
docker image prune --all --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, which may be expensive to rebuild.
Docuum is ideal for use cases such as continuous integration workers, developer workstations, or any other environment in which Docker images accumulate on disk over time. Docuum works well with tools like Toast and Docker Compose.
Docuum is used by Airbnb on its fleet of 1.5k+ CI workers.
Docker doesn't record when an image was last used. To work around this, Docuum listens for notifications via
docker eventsto 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 a few advantages over evicting images based on a fixed time to live (TTL), which is what various other tools in the Docker ecosystem do:
Docuum also respects the parent-child relationships between images. In particular, it will delete children of a parent before deleting the parent (even if the children were used more recently than the parent), because Docker doesn't allow images with children to be deleted.
Docuum is meant to be started once and run forever, rather than as a cron job. Once Docuum is installed, you can run it from the command line as follows:
$ docuum --threshold '30 GB'
You probably want to run Docuum as a daemon, e.g., with launchd, systemd, etc. You may consult your operating system documentation for instructions on how to do that. For macOS, for example, you can create a file (owned by root) called
/Library/LaunchDaemons/local.docuum.plistwith the following:
Label local.docuum Program /usr/local/bin/docuum ProgramArguments /usr/local/bin/docuum --threshold 10 GB StandardOutPath /var/log/docuum.log StandardErrorPath /var/log/docuum.log EnvironmentVariables PATH /bin:/usr/bin:/usr/local/bin KeepAlive
Now Docuum will start automatically when you restart your machine, and the logs can be found at
/var/log/docuum.log. If you do not wish to restart your machine, you can run
sudo launchctl load /Library/LaunchDaemons/local.docuum.plistto start the daemon.
Here are the supported command-line options:
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 prefer not to install Docuum on your system, you can run it in a container. To run it in the foreground, you can use a command like the following:
docker run \ --init \ --rm \ --tty \ --name docuum \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume docuum:/root \ stephanmisc/docuum --threshold '15 GB'
To run it in the background:
docker run \ --detach \ --init \ --rm \ --name docuum \ --volume /var/run/docker.sock:/var/run/docker.sock \ --volume docuum:/root \ stephanmisc/docuum --threshold '15 GB'
If you are running macOS or a GNU-based Linux on an x86-64 CPU, you can install Docuum with this command:
curl https://raw.githubusercontent.com/stepchowfun/docuum/main/install.sh -LSfs | sh
The same command can be used again to update Docuum to the latest version.
shis 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)
For example, the following will install Docuum into the working directory:
curl https://raw.githubusercontent.com/stepchowfun/docuum/main/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
If you have Cargo, you can install Docuum as follows:
cargo install docuum
You can run that command with
--forceto update an existing installation.
docker builder prune --all --force --keep-storage '30 GB'). If you are not using BuildKit mode, Docker's caching mechanism uses intermediate images, and Docuum will happily vacuum such images as usual.