Public | Automated Build

Last pushed: 7 months ago
Short Description
This container runs as a daemon on kubernetes and cleans up old images
Full Description

Image Cleaner

This is a docker container which, cleans up docker containers (and images). We noticed that people (and build servers) were getting clogged up with old images and stopped containers and people were getting stick of typing things like docker ps -aq | grep Exited | xargs -n 1 docker rm... and so on.

Running once

To do a single cleanup, type docker-compose run --rm image.cleaner --once. You can do a dry run if you prefer, to see what would be deleted with docker-compose run --rm image.cleaner --dry.

Schedule

By default, if you just did docker-compose run --rm image.cleaner then you will get an initial cleanup run, followed by a 3am cron like schedule. This is intentional as we actually run this as a kubernetes DaemonSet (see kubernetes/image-cleaner.daemon.yml) on our build servers to clean up.

Looks for

Anything matching <none> or eu.gcr.io/peopledata-product-team as these are our current requirements. It is inclusive, rather than exclusive, because we didn't want it accidentaly deleting important pods we had missed. Fork it and modify if you need something else :D

Outputs

Something like this:

$ k logs image-cleaner-b2vga
Cleaning...
Processing images with <none> repositories or tags
 [i] Removing 37474ad3992d
Deleted: sha256:37474ad3992dc545f7aabce5a49494bb724d40e0b4d21a49b9fbc74eb2788a26
Deleted: sha256:0f7a434f2ee990a3f038459775936b6478501f1fe31bbf6dbf3bb52ab7f19122
Processing tagged images
Processing repository eu.gcr.io/peopledata-product-team/image-cleaner
 [i] eu.gcr.io/peopledata-product-team/image-cleaner has 1 images
Processing repository eu.gcr.io/peopledata-product-team/gocd.agent
 [i] eu.gcr.io/peopledata-product-team/gocd.agent has 5 images
Processing repository eu.gcr.io/peopledata-product-team/td.dashboard
 [i] eu.gcr.io/peopledata-product-team/td.dashboard has 5 images
Processing repository eu.gcr.io/peopledata-product-team/td.rabbitmq
 [i] eu.gcr.io/peopledata-product-team/td.rabbitmq has 5 images
Processing repository eu.gcr.io/peopledata-product-team/td.redis
 [i] eu.gcr.io/peopledata-product-team/td.redis has 5 images
Processing repository eu.gcr.io/peopledata-product-team/td.distribution
 [i] eu.gcr.io/peopledata-product-team/td.distribution has 5 images
Processing repository eu.gcr.io/peopledata-product-team/td.gateway
 [i] eu.gcr.io/peopledata-product-team/td.gateway has 5 images
Processing repository eu.gcr.io/peopledata-product-team/gocd.master
 [i] eu.gcr.io/peopledata-product-team/gocd.master has 1 images
Processing repository eu.gcr.io/peopledata-product-team/gocd.nginx
 [i] eu.gcr.io/peopledata-product-team/gocd.nginx has 1 images
Clean complete
Docker Pull Command
Owner
peopledata
Source Repository

Comments (0)