It's Deis specific approach to docker image
cleanup. Currently available solutions are too io heavy or aren't configurable
enough.
Use environment variables to pass the configuration. For example:
docker run --env "ENV_NAME=value" ...`
Possible options:
KEEP_LAST_VERSIONS
- the number of releases to keep for each repository (default:2
).DRY_RUN
- just print the commands (default:false
).EXCLUDE_REGEX
- regex filter for repository name (default:alpine|deis|blackhole|none|datadog|cleanup|heroku|python
).CLEANUP_CONTAINERS
- cleanup exited containers (default:true
)
- Log onto the
deis-builder
container:
$ fleetctl ssh deis-builder
$ nse deis-builder
- Pull
deis-cleanup
image:
$ docker pull twobox/deis-cleanup
- Run
deis-cleanup
:
$ docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm twobox/deis-cleanup
Repeat for each Deis node:
- Log onto a node:
$ fleetctl ssh <machine id>
- Follow steps 2. and 3. from usage on
deis-builder
.
- Load the service:
$ fleetctl load deis-cleanup.service
- Start the service:
$ fleetctl start deis-cleanup.service
- Wait until the process will finish and destroy it (optional):
$ fleetctl destroy deis-cleanup.service
- Update the code.
- Build:
$ docker build -t twobox/deis-cleanup .
...
Successfully built 902499c7cfb8
- Tag:
$ docker images | grep deis-cleanup
deis-cleanup latest 902499c7cfb8 6 minutes ago 143.5 MB
$ docker tag 902499c7cfb8 twobox/deis-cleanup:latest
$ docker images | grep deis-cleanup
deis-cleanup latest 902499c7cfb8 10 minutes ago 143.5 MB
twobox/deis-cleanup latest 902499c7cfb8 10 minutes ago 143.5 MB
- Login (optional, it has to be done only once):
$ docker login --username=<login> --email=<email>
Password:
WARNING: login credentials saved in <home>/.docker/config.json
Login Succeeded
- Push:
$ docker push twobox/deis-cleanup
The push refers to a repository [docker.io/twobox/deis-cleanup]
...
latest: digest: sha256:cdc617c74cc2b8332eaa0f844571309e7b291f1b483a7372a316d62395e0b3f1 size: 12968