Small binary to clean up docker images (mostly in CI)
This repository has been archived on 2024-03-03. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
DataHearth 2d5714c9c6
use docker socket
2022-03-16 23:59:07 +01:00
.github/workflows add release workflow 2022-03-06 22:05:15 +01:00
src invert condition for empty tags 2022-03-16 13:59:16 +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 add --all-features to build 2022-03-16 13:58:58 +01:00
LICENSE add license 2022-02-09 00:04:02 +01:00
Makefile use docker socket 2022-03-16 23:59:07 +01:00
README.md update readme 2022-03-06 22:16:08 +01:00

README.md

clear-docker-images

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

Usage

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 ghcr.io/datahearth/clear-docker-images <OPTIONS>

Binary

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 ~/. https://github.com/DataHearth/clear-docker-images/releases/download/<VERSION>/<BINARY>

clear-docker-images <OPTIONS>

Source

git clone https://github.com/DataHearth/clear-docker-images.git
cd clear-docker-images
cargo install --path .

clear-docker-images <OPTIONS>

Options

USAGE:
    clear-docker-images [OPTIONS] [REPOSITORY]

ARGS:
    <REPOSITORY>
            filter by repository name

OPTIONS:
    -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]

        --dry-run
            image cleanup will not be triggered [default: false]

        --force
            force image removal [default: false]

    -h, --help
            Print help information

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

    -v, --verbose
            add more logs [default: false]

    -V, --version
            Print version information