Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 1.23 KB

README.md

File metadata and controls

31 lines (20 loc) · 1.23 KB

docker-gc

Author: Gonzalo Marcote - [email protected]

License: GNU General Public License V3.0

Disclaimer: For my own use. Use on your own (GNU GPL License). Don't give any support

Simple docker garbage collection that removes exited containers and dangling images

Usage

Build it locally:
$ docker build -t cbyg/docker-gc .

Loging to AWS repository if necessary:
$ aws ecr get-login --region eu-west-1 | sh -

Tag it:
$ docker tag cbyg/docker-gc:latest XXX.dkr.ecr.eu-west-1.amazonaws.com/cbyg/docker-gc:latest

Push it to ECR:
$ docker push XXX.dkr.ecr.eu-west-1.amazonaws.com/cbyg/docker-gc:latest

Run as cron job (every X minutes - edit Dockerfile):
docker run --restart=always --name docker-gc -d -v /var/run/docker.sock:/var/run/docker.sock cbyg/docker-gc:latest
docker run --restart=always --name docker-gc -d -v /var/run/docker.sock:/var/run/docker.sock XXX.dkr.ecr.eu-west-1.amazonaws.com/docker-gc:latest

Run a one-off:
docker run --name docker-gc --rm -it -v /var/run/docker.sock:/var/run/docker.sock cbyg/docker-gc:latest docker-gc
docker run --name docker-gc --rm -it -v /var/run/docker.sock:/var/run/docker.sock XXX.dkr.ecr.eu-west-1.amazonaws.com/docker-gc:latest docker-gc