Go to file
2018-03-09 10:54:19 -08:00
debian Get tests working again by updating git pre-hooks 2018-03-03 22:10:49 -05:00
docker_custodian Instantiate APIClient using defined envars e.g. DOCKER_HOST 2018-03-07 08:45:00 -05:00
tests Port from 'docker-py' library to renamed 'docker' library. 2018-03-06 09:56:19 -05:00
.dockerignore Add a container to run docker-custodian and install instructions to the README. 2015-08-08 18:11:22 -04:00
.gitignore Adding project files 2015-07-08 12:33:52 -07:00
.pre-commit-config.yaml Updated pre-commit-config 2018-03-04 00:21:08 -05:00
.travis.yml Update travis config and python to newer versions 2018-03-05 09:21:00 -05:00
CHANGELOG.md Fix release for 0.6.1 2016-08-31 09:57:49 -07:00
Dockerfile Update the readme to reflect that the official docker image. Fixes #16 2015-09-29 10:57:23 -07:00
LICENSE Adding project files 2015-07-08 12:33:52 -07:00
Makefile Add a container to run docker-custodian and install instructions to the README. 2015-08-08 18:11:22 -04:00
README.rst Add pattern matching info to README.rst 2016-10-04 12:23:40 +03:00
requirements.txt Update requirements.txt version and use docker instead of docker-py 2018-03-06 09:51:04 -05:00
setup.py Port from 'docker-py' library to renamed 'docker' library. 2018-03-06 09:56:19 -05:00
tox.ini Update travis config and python to newer versions 2018-03-05 09:21:00 -05:00

Docker Custodian
================

.. image:: https://travis-ci.org/Yelp/docker-custodian.svg
    :target: https://travis-ci.org/Yelp/docker-custodian

Keep docker hosts tidy.


.. contents::
    :backlinks: none

Install
-------

There are three installation options

Container
~~~~~~~~~

.. code::

    docker pull yelp/docker-custodian
    docker run -ti \
        -v /var/run/docker.sock:/var/run/docker.sock \
        yelp/docker-custodian dcgc --help

Debian/Ubuntu package
~~~~~~~~~~~~~~~~~~~~~

First build the package (requires `dh-virtualenv`)

.. code:: sh

    dpkg-buildpackage -us -uc

Then install it

.. code:: sh

    dpkg -i ../docker-custodian_*.deb


Source
~~~~~~

.. code:: sh

    pip install git+https://github.com/Yelp/docker-custodian.git#egg=docker_custodian


dcgc
----

Remove old docker containers and docker images.

``dcgc`` 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:

.. code:: sh

    dcgc --max-container-age 3days --max-image-age 30days


Prevent images from being removed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``dcgc`` 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.

::

    --exclude-image
        Never remove images with this tag. May be specified more than once.

    --exclude-image-file
        Path to a file which contains a list of images to exclude, one
        image tag per line.

You also can use basic pattern matching to exclude images with generic tags.

.. code::

    user/repositoryA:*
    user/repositoryB:?.?
    user/repositoryC-*:tag

dcstop
------

Stop containers that have been running for too long.

``dcstop`` will ``docker stop`` containers where the container name starts
with `--prefix` and it has been running for longer than `--max-run-time`.


Example:

.. code:: sh

    dcstop --max-run-time 2days --prefix "projectprefix_"