Small binary to clean up docker images (mostly in CI)
Go to file
DataHearth d38ea8cd72
update earthfile
2022-08-26 13:08:47 +02:00
.github/workflows add earthly container image stage 2022-03-16 23:59:33 +01:00
src bump v0.5.0 2022-03-17 00:02:20 +01:00
.earthlyignore add earthly push option 2022-03-06 23:34:09 +01:00
.gitignore update build steps 2022-03-05 23:59:11 +01:00
Cargo.lock use docker socket 2022-03-16 23:59:07 +01:00
Cargo.toml use docker socket 2022-03-16 23:59:07 +01:00
Earthfile update earthfile 2022-08-26 13:08:47 +02:00
LICENSE add license 2022-02-09 00:04:02 +01:00
Makefile use docker socket 2022-03-16 23:59:07 +01:00 bump v0.5.0 2022-03-17 00:02:20 +01:00


clear-docker-images is a small rust binary made to cleanup old docker images by date, repository and tags.


By default, clear-docker-images will select images that are older than 2 days old. You can choose to customize its behavior by filtering a different date by passing 1 or 2 dates, a repository and tags.

Docker container

docker run --name clear-docker-image -v /var/run/docker.sock:/var/run/docker.sock <OPTIONS>

N.B: Since v0.5.0, container images switched from the Docker alpine docker-in-docker image to Debian 11 distroless. I recommand switching to v0.5.0 for a significant size gain (around x20 in term of image size => 230MB).


mkdir -p $HOME/.local/bin
export PATH=$PATH:$HOME/.local/bin

# Available binaries:
# x86_64-unknown-linux-gnu | x86_64-unknown-linux-musl | x86_64-apple-darwin
wget -o $HOME/.local/bin/clear-docker-images ~/.<VERSION>/<BINARY>

clear-docker-images <OPTIONS>


git clone
cd clear-docker-images
cargo install --path .

clear-docker-images <REPOSITORY> <OPTIONS>


    clear-docker-images [OPTIONS] [REPOSITORY]

            filter by repository name

    -d, --date <DATE>
            filter by date.

            Can filter by a minimum age $DATE or from $START|$STOP (format example: YYYY-MM-DD or
            YYYY-MM-DDTHH:MM:SS) [default: $NOW - 2d]

            image cleanup will not be triggered [default: false]

    -f, --force
            should force image deletion [default: false]

    -h, --help
            Print help information

    -s, --socket <SOCKET>
            where is located the docker socket (can be a UNIX socket or TCP protocol)

            [default: /var/run/docker.sock]

    -t, --tags <TAGS>
            add tags exclusion

    -V, --version
            Print version information