diff --git a/CHANGELOG.md b/CHANGELOG.md index 909b4eb..3e41043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1 @@ -* Initial release +* Initial release after fork diff --git a/Dockerfile b/Dockerfile index 965823a..95f1e9a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,4 +20,4 @@ RUN \ USER root CMD [] -ENTRYPOINT ["/usr/local/bin/docker-tidy"] +ENTRYPOINT ["/usr/local/bin/docker-tidy gc"] diff --git a/README.md b/README.md index 71692ac..f5d1a80 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![PyPi Release](https://img.shields.io/pypi/v/docker-tidy.svg)](https://pypi.org/project/docker-tidy/) [![License: MIT](https://img.shields.io/github/license/xoxys/docker-tidy)](LICENSE) -This is a fork of [Yelp/docker-custodian](https://github.com/Yelp/docker-custodian). Keep docker hosts tidy. +This project is a fork of [Yelp/docker-custodian](https://github.com/Yelp/docker-custodian). Keep docker hosts tidy. You can find the full documentation at [https://docker-tidy.geekdocs.de](https://docker-tidy.geekdocs.de/). diff --git a/dockertidy/Config.py b/dockertidy/Config.py index 0554e6f..c14dc28 100644 --- a/dockertidy/Config.py +++ b/dockertidy/Config.py @@ -40,7 +40,7 @@ class Config(): }, "dry_run": { "default": False, - "env": "DRY_TUN", + "env": "DRY_RUN", "file": True, "type": environs.Env().bool }, diff --git a/docs/.keep b/docs/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/content/_index.md b/docs/content/_index.md index bdce6ed..77ec135 100644 --- a/docs/content/_index.md +++ b/docs/content/_index.md @@ -9,78 +9,4 @@ title: Documentation [![PyPi Release](https://img.shields.io/pypi/v/docker-tidy.svg)](https://pypi.org/project/docker-tidy/) [![License: MIT](https://img.shields.io/github/license/xoxys/docker-tidy)](LICENSE) -## Install - -There are three installation options - -### Container - -```Shell -docker pull xoxys/docker-tidy -docker run -ti \ - -v /var/run/docker.sock:/var/run/docker.sock \ - xoxys/docker-tidy docker-tidy gc --help -``` - -### Source - -```Shell -pip install git+https://github.com/xoxys/docker-tidy.git -``` - -## Garbage Collector - -Remove old docker containers and docker images. - -`docker-tidy gc` will remove stopped containers and unused images that are older -than \"max age\". Running containers, and images which are used by a -container are never removed. - -Maximum age can be specificied with any format supported by -[pytimeparse]. - -Example: - -```Shell -docker-tidy gc --max-container-age 3days --max-image-age 30days -``` - -### Prevent images from being removed - -`docker-tidy gc` supports an image exclude list. If you have images that you\'d -like to keep around forever you can use the exclude list to prevent them -from being removed. - -```Shell - --exclude-image - Never remove images with this tag. May be specified more than once. -``` - -### Prevent containers and associated images from being removed - -`docker-tidy gc` also supports a container exclude list based on labels. If there -are stopped containers that you\'d like to keep, then you can check the -labels to prevent them from being removed. - -```Shell - --exclude-container-label - Never remove containers that have the label key=value. =value can be - omitted and in that case only the key is checked. May be specified - more than once. -``` - -## Autostop - -Stop containers that have been running for too long. - -`docker-tidy stop` will `docker stop` containers where the container name starts -with [\--prefix]{.title-ref} and/or it has been running for longer than -[\--max-run-time]{.title-ref}. - -If no prefix is set, __all__ containers matching the `max-run-time` will be stopped! - -Example: - -```Shell -docker-tidy stop --max-run-time 2days --prefix "projectprefix_" -``` +This project is a fork of [Yelp/docker-custodian](https://github.com/Yelp/docker-custodian). Keep docker hosts tidy. diff --git a/docs/content/configuration/_index.md b/docs/content/configuration/_index.md new file mode 100644 index 0000000..4cc50a6 --- /dev/null +++ b/docs/content/configuration/_index.md @@ -0,0 +1,80 @@ +--- +title: Configuration +--- + +*docker-tidy* comes with default settings which should be sufficient for most users to start, but you can adjust most settings to your needs. + +Changes can be made on different locations which will be processed in the following order (last wins): + +* default config (build-in) +* global config file (path depends on your operating system) +* folder-based config file (.dockertidy.yml|.dockertidy.yaml|.dockertidy in current working dir) +* environment variables +* cli options + +## Default settings + + +{{< highlight YAML "linenos=table" >}} +--- +# don't do anything +dry_run: False + +logging: + # possible options debug | info | warning | error | critical + level: "warning" + # you can enable json logging if a parsable output is required + json: False + +{{< /highlight >}} + + +## Environment Variables + + +{{< highlight Shell "linenos=table" >}} +TIDY_CONFIG_FILE= +TIDY_DRY_RUN=False +TIDY_HTTP_TIMEOUT=60 +TIDY_LOG_LEVEL=warning +TIDY_LOG_JSON=False +TIDY_GC_MAX_CONTAINER_AGE= +TIDY_GC_MAX_IMAGE_AGE= +TIDY_GC_DANGLING_VOLUMES=False +# comma-separated list +TIDY_GC_EXCLUDE_IMAGES= +# comma-separated list +TIDY_GC_EXCLUDE_CONTAINER_LABELS= +TIDY_STOP_MAX_RUN_TIME= +# comma-separated list +TIDY_STOP_PREFIX= +{{< /highlight >}} + + +## CLI options + +You can get all available cli options by running `docker-tidy --help`: + + +{{< highlight Shell "linenos=table" >}} +$ docker-tidy --help +usage: docker-tidy [-h] [--dry-run] [-t HTTP_TIMEOUT] [-v] [-q] [--version] + {gc,stop} ... + +Generate documentation from annotated Ansible roles using templates + +positional arguments: + {gc,stop} sub-command help + gc Run docker garbage collector. + stop Stop containers that have been running for too long. + +optional arguments: + -h, --help show this help message and exit + --dry-run Only log actions, don't stop anything. + -t HTTP_TIMEOUT, --timeout HTTP_TIMEOUT + HTTP timeout in seconds for making docker API calls. + -v increase log level + -q decrease log level + --version show program's version number and exit +{{< /highlight >}} + diff --git a/docs/content/setup/_index.md b/docs/content/setup/_index.md new file mode 100644 index 0000000..aef4749 --- /dev/null +++ b/docs/content/setup/_index.md @@ -0,0 +1,37 @@ +--- +title: Setup +--- + +## Pip + + +{{< highlight Shell "linenos=table" >}} +# From PyPI as unprivilegd user +$ pip install docker-tidy --user + +# .. or as root +$ sudo pip install docker-tidy + +# From Wheel file +$ pip install https://github.com/xoxys/docker-tidy/releases/download/v0.1.0/docker_tidy-0.1.0-py2.py3-none-any.whl +{{< /highlight >}} + + +## Docker + + +{{< highlight Shell "linenos=table" >}} +docker run \ + -e TIDY_GC_MAX_CONTAINER_AGE=3days + -e TIDY_GC_MAX_IMAGE_AGE=5days + -v /var/run/docker.sock:/var/run/docker.sock + xoxys/docker-tidy +{{< /highlight >}} + + + +{{< hint info >}} +**Info**\ +Keep in mind, that you have to pass selinux labels (:Z or :z) to your mount option if you are working on selinux enabled systems. +{{< /hint >}} + diff --git a/docs/content/usage/_index.md b/docs/content/usage/_index.md new file mode 100644 index 0000000..fe5ba36 --- /dev/null +++ b/docs/content/usage/_index.md @@ -0,0 +1,60 @@ +--- +title: Usage +--- + +## Garbage Collector + +Remove old docker containers and docker images. + +`docker-tidy gc` will remove stopped containers and unused images that are older +than \"max age\". Running containers, and images which are used by a +container are never removed. + +Maximum age can be specificied with any format supported by +[pytimeparse](https://github.com/wroberts/pytimeparse). + +__Example:__ + +```Shell +docker-tidy gc --max-container-age 3days --max-image-age 30days +``` + +### Prevent images from being removed + +`docker-tidy gc` supports an image exclude list. If you have images that you\'d +like to keep around forever you can use the exclude list to prevent them +from being removed. + +```Shell + --exclude-image + Never remove images with this tag. May be specified more than once. +``` + +### Prevent containers and associated images from being removed + +`docker-tidy gc` also supports a container exclude list based on labels. If there +are stopped containers that you\'d like to keep, then you can check the +labels to prevent them from being removed. + +```Shell + --exclude-container-label + Never remove containers that have the label key=value. =value can be + omitted and in that case only the key is checked. May be specified + more than once. +``` + +## Autostop + +Stop containers that have been running for too long. + +`docker-tidy stop` will `docker stop` containers where the container name starts +with [\--prefix]{.title-ref} and/or it has been running for longer than +[\--max-run-time]{.title-ref}. + +If no prefix is set, __all__ containers matching the `max-run-time` will be stopped! + +__Example:__ + +```Shell +docker-tidy stop --max-run-time 2days --prefix "projectprefix_" +``` diff --git a/docs/data/menu/main.yml b/docs/data/menu/main.yml new file mode 100644 index 0000000..23ea909 --- /dev/null +++ b/docs/data/menu/main.yml @@ -0,0 +1,8 @@ +--- +main: + - name: Setup + ref: "/setup" + - name: Configuration + ref: "/configuration" + - name: Usage + ref: "/usage" diff --git a/docs/data/menu/more.yml b/docs/data/menu/more.yml new file mode 100644 index 0000000..23b0129 --- /dev/null +++ b/docs/data/menu/more.yml @@ -0,0 +1,10 @@ +--- +more: + - name: Releases + ref: "https://github.com/xoxys/docker-tidy/releases" + external: true + icon: "download" + - name: "View Source" + ref: "https://github.com/xoxys/docker-tidy" + external: true + icon: "github" diff --git a/docs/static/.htaccess b/docs/static/.htaccess new file mode 100644 index 0000000..b5a07f4 --- /dev/null +++ b/docs/static/.htaccess @@ -0,0 +1,16 @@ +ErrorDocument 404 /404.html + +ExpiresActive On +ExpiresDefault "access plus 600 seconds" +ExpiresByType text/css "access plus 1 week" +ExpiresByType text/javascript "access plus 1 month" +ExpiresByType text/html "access plus 1 seconds" +ExpiresByType application/javascript "access plus 1 month" +ExpiresByType application/x-javascript "access plus 1 month" +ExpiresByType image/gif "access plus 1 week" +ExpiresByType image/jpeg "access plus 1 week" +ExpiresByType image/png "access plus 1 week" +ExpiresByType image/x-icon "access plus 1 month" +ExpiresByType image/svg+xml "access plus 1 week" +ExpiresByType application/x-font-woff "access plus 1 week" +ExpiresByType application/font-woff2 "access plus 1 week"