docker-custodian

Keep docker hosts tidy

  • 所有者: Yelp/docker-custodian
  • 平台:
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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

Prevent containers and associated images from being removed


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

::

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

You also can use basic pattern matching to exclude generic labels.

.. code::

    foo*
    com.docker.compose.project=test*
    com.docker*=*bar*


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_"

概览

名称与所有者Yelp/docker-custodian
主编程语言Python
编程语言Makefile (语言数: 3)
平台
许可证Apache License 2.0
发布数7
最新版本名称v0.7.4 (发布于 )
第一版名称v0.4.0 (发布于 )
创建于2015-06-29 21:30:58
推送于2023-07-25 15:10:23
最后一次提交2022-06-30 19:21:22
星数354
关注者数43
派生数50
提交数103
已启用问题?
问题数23
打开的问题数8
拉请求数30
打开的拉请求数8
关闭的拉请求数3
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?
去到顶部