Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here


Keep docker hosts tidy

Subscribe to updates I use docker-custodian

Statistics on docker-custodian

Number of watchers on Github 269
Number of open issues 13
Average time to close an issue about 1 month
Main language Python
Average time to merge a PR 5 days
Open pull requests 8+
Closed pull requests 1+
Last commit over 1 year ago
Repo Created over 4 years ago
Repo Last Updated over 1 year ago
Size 61 KB
Organization / Authoryelp
Page Updated
Do you use docker-custodian? Leave a review!
View open issues (13)
View docker-custodian activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating docker-custodian for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Docker Custodian

.. image:: :target:

Keep docker hosts tidy.

.. contents:: :backlinks: none


There are three installation options


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


.. code:: sh

    pip install git+


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


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


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

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



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.


.. code:: sh

dcstop --max-run-time 2days --prefix "projectprefix_"
docker-custodian open issues Ask a question     (View All Issues)
  • over 3 years use events to do image cleanup correctly
  • over 3 years dcgc does not detect :latest automatically
  • about 4 years question: cannot delete because running container is using it
  • about 4 years Use kwargs_from_env() to get Client kwargs
  • about 4 years Support exclude containers
  • over 4 years A tool to cleanup old layers in a docker registry
  • over 4 years Support labels to identify containers to dcstop
  • over 4 years Exclude some images from dcgc
docker-custodian open pull requests (View All Pulls)
  • added instruction for the pip module of ansible
  • To remove any associated volumes when removing containers
  • Do not force people to install python2.7
  • Fix broken filtering for images used by containers
  • Add --max-tags-count parameter
  • Add support for stopping containers by image
  • Correctly handle empty dangling volumes
  • Add --exclude-container-label argument to dcgc
docker-custodian list of languages used
Other projects in Python