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.
clear-docker-images/README.md

77 lines
2.1 KiB
Markdown
Raw Permalink Normal View History

2022-02-09 00:03:09 +01:00
# clear-docker-images
2022-02-20 18:39:10 +01:00
`clear-docker-images` is a small rust binary made to cleanup old docker images by date, repository and tags.
2022-02-09 00:03:09 +01:00
## Usage
2022-02-20 18:39:10 +01:00
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.
2022-02-09 00:07:38 +01:00
2022-02-09 00:03:09 +01:00
### Docker container
```bash
2022-02-17 22:17:13 +01:00
docker run --name clear-docker-image -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/datahearth/clear-docker-images <OPTIONS>
2022-02-09 00:03:09 +01:00
```
2022-03-16 14:16:31 +01:00
*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).*
2022-02-09 00:03:09 +01:00
### Binary
```bash
mkdir -p $HOME/.local/bin
export PATH=$PATH:$HOME/.local/bin
2022-03-06 22:16:08 +01:00
# 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>
2022-02-09 00:03:09 +01:00
clear-docker-images <OPTIONS>
```
### Source
```bash
git clone https://github.com/DataHearth/clear-docker-images.git
cd clear-docker-images
cargo install --path .
2022-03-16 14:16:31 +01:00
clear-docker-images <REPOSITORY> <OPTIONS>
2022-02-09 00:03:09 +01:00
```
2022-03-06 14:35:15 +01:00
## Options
2022-02-09 00:03:09 +01:00
2022-02-17 22:17:13 +01:00
```bash
2022-03-06 14:35:15 +01:00
USAGE:
clear-docker-images [OPTIONS] [REPOSITORY]
2022-02-20 18:39:10 +01:00
2022-03-06 14:35:15 +01:00
ARGS:
<REPOSITORY>
filter by repository name
2022-02-20 18:39:10 +01:00
2022-03-06 14:35:15 +01:00
OPTIONS:
-d, --date <DATE>
filter by date.
2022-02-20 18:39:10 +01:00
2022-03-06 14:35:15 +01:00
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]
2022-02-20 18:39:10 +01:00
2022-03-06 14:35:15 +01:00
--dry-run
image cleanup will not be triggered [default: false]
2022-02-20 18:39:10 +01:00
2022-03-16 23:57:15 +01:00
-f, --force
should force image deletion [default: false]
2022-03-06 14:35:15 +01:00
-h, --help
Print help information
2022-02-20 18:39:10 +01:00
2022-03-16 14:16:31 +01:00
-s, --socket <SOCKET>
where is located the docker socket (can be a UNIX socket or TCP protocol)
[default: /var/run/docker.sock]
2022-03-06 14:35:15 +01:00
-t, --tags <TAGS>
add tags exclusion
2022-02-20 18:39:10 +01:00
2022-03-06 14:35:15 +01:00
-V, --version
Print version information
2022-02-17 22:17:13 +01:00
```