{"id":13416581,"url":"https://github.com/Yelp/docker-custodian","last_synced_at":"2025-03-15T00:31:09.326Z","repository":{"id":34350853,"uuid":"38272402","full_name":"Yelp/docker-custodian","owner":"Yelp","description":"Keep docker hosts tidy","archived":false,"fork":false,"pushed_at":"2024-08-14T08:08:10.000Z","size":114,"stargazers_count":373,"open_issues_count":15,"forks_count":50,"subscribers_count":42,"default_branch":"master","last_synced_at":"2025-03-12T22:35:43.369Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yelp.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-29T21:30:58.000Z","updated_at":"2025-02-23T15:33:35.000Z","dependencies_parsed_at":"2024-01-07T10:50:50.535Z","dependency_job_id":"3d8eb97b-8655-47ed-9ba4-013d4b03f4a0","html_url":"https://github.com/Yelp/docker-custodian","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yelp%2Fdocker-custodian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yelp%2Fdocker-custodian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yelp%2Fdocker-custodian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yelp%2Fdocker-custodian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yelp","download_url":"https://codeload.github.com/Yelp/docker-custodian/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243667721,"owners_count":20328032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T21:01:01.366Z","updated_at":"2025-03-15T00:31:08.967Z","avatar_url":"https://github.com/Yelp.png","language":"Python","funding_links":[],"categories":["Development with Docker","Python","Running Containers"],"sub_categories":["Garbage Collection"],"readme":"Docker Custodian\n================\n\n.. |tests badge| image:: https://github.com/yelp/docker-custodian/actions/workflows/tests.yml/badge.svg\n.. |docker badge| image:: https://github.com/yelp/docker-custodian/actions/workflows/docker.yml/badge.svg\n.. |pypi badge| image:: https://github.com/yelp/docker-custodian/actions/workflows/publish.yml/badge.svg\n\n|tests badge| |docker badge| |pypi badge|\n\nKeep docker hosts tidy.\n\n\n.. contents::\n    :backlinks: none\n\nInstall\n-------\n\nThere are three installation options\n\nContainer\n~~~~~~~~~\n\n.. code::\n\n    docker pull yelp/docker-custodian\n    docker run -ti \\\n        -v /var/run/docker.sock:/var/run/docker.sock \\\n        yelp/docker-custodian --help\n\nDebian/Ubuntu package\n~~~~~~~~~~~~~~~~~~~~~\n\nFirst build the package (requires `dh-virtualenv`)\n\n.. code:: sh\n\n    dpkg-buildpackage -us -uc\n\nThen install it\n\n.. code:: sh\n\n    dpkg -i ../docker-custodian_*.deb\n\n\npypi.org\n~~~~~~~~\n\n.. code:: sh\n\n    pip install docker-custodian\n\n\ndcgc\n----\n\nRemove old docker containers and docker images.\n\n``dcgc`` will remove stopped containers and unused images that are older than\n\"max age\".  Running containers, and images which are used by a container are\nnever removed.\n\nMaximum age can be specificied with any format supported by\n`pytimeparse \u003chttps://github.com/wroberts/pytimeparse\u003e`_.\n\nExample:\n\n.. code:: sh\n\n    dcgc --max-container-age 3days --max-image-age 30days\n\n\nPrevent images from being removed\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``dcgc`` supports an image exclude list. If you have images that you'd like\nto keep around forever you can use the exclude list to prevent them from\nbeing removed.\n\n::\n\n    --exclude-image\n        Never remove images with this tag. May be specified more than once.\n\n    --exclude-image-file\n        Path to a file which contains a list of images to exclude, one\n        image tag per line.\n\nYou also can use basic pattern matching to exclude images with generic tags.\n\n.. code::\n\n    user/repositoryA:*\n    user/repositoryB:?.?\n    user/repositoryC-*:tag\n\n\nPrevent containers and associated images from being removed\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n``dcgc`` also supports a container exclude list based on labels.  If there are\nstopped containers that you'd like to keep, then you can check the labels to\nprevent them from being removed.\n\n::\n\n    --exclude-container-label\n        Never remove containers that have the label key=value. =value can be\n        omitted and in that case only the key is checked. May be specified\n        more than once.\n\nYou also can use basic pattern matching to exclude generic labels.\n\n.. code::\n\n    foo*\n    com.docker.compose.project=test*\n    com.docker*=*bar*\n\n\ndcstop\n------\n\nStop containers that have been running for too long.\n\n``dcstop`` will ``docker stop`` containers where the container name starts\nwith `--prefix` and it has been running for longer than `--max-run-time`.\n\n\nExample:\n\n.. code:: sh\n\n    dcstop --max-run-time 2days --prefix \"projectprefix_\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYelp%2Fdocker-custodian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYelp%2Fdocker-custodian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYelp%2Fdocker-custodian/lists"}