From 2301aa91f47a6520ff4afd0ee04a35903feb70df Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sat, 21 Nov 2020 15:28:03 +0200 Subject: [PATCH] Docker clean. Run the docker-clean image daily. Remove failed builds and such. --- crond/.dockerignore | 2 ++ crond/Dockerfile | 8 ++++++++ crond/README.md | 20 ++++++++++++++++++++ crond/crontab | 1 + docker-compose.yml | 5 +++++ 5 files changed, 36 insertions(+) create mode 100644 crond/.dockerignore create mode 100644 crond/Dockerfile create mode 100644 crond/README.md create mode 100644 crond/crontab diff --git a/crond/.dockerignore b/crond/.dockerignore new file mode 100644 index 0000000..780ece0 --- /dev/null +++ b/crond/.dockerignore @@ -0,0 +1,2 @@ +* +!crontab diff --git a/crond/Dockerfile b/crond/Dockerfile new file mode 100644 index 0000000..994fbce --- /dev/null +++ b/crond/Dockerfile @@ -0,0 +1,8 @@ +FROM docker:19.03 as docker + +# hadolint ignore=DL3006 +FROM adarnimrod/cron as supersonic +COPY --from=docker /usr/local/bin/docker /usr/local/bin/ +COPY --chown=root:root crontab /crontab +# hadolint ignore=DL3002 +USER root diff --git a/crond/README.md b/crond/README.md new file mode 100644 index 0000000..9ea96a5 --- /dev/null +++ b/crond/README.md @@ -0,0 +1,20 @@ +# crond + +> Cron container image. + +## Description + +This container periodically runs the [docker-clean +image](https://hub.docker.com/r/adarnimrod/docker-clean). For this the `dockerd` +socket is bind mounted to this container. + +## License + +This software is licensed under the MIT license (see `LICENSE.txt`). + +## Author Information + +Nimrod Adar, [contact me](mailto:nimrod@shore.co.il) or visit my [website]( +https://www.shore.co.il/). Patches are welcome via [`git send-email`]( +http://git-scm.com/book/en/v2/Git-Commands-Email). The repository is located +at: <https://git.shore.co.il/nimrod/>. diff --git a/crond/crontab b/crond/crontab new file mode 100644 index 0000000..022e85b --- /dev/null +++ b/crond/crontab @@ -0,0 +1 @@ +@daily docker run --rm --name=docker-clean --volume /var/run/docker.sock:/var/run/docker.sock adarnimrod/docker-clean diff --git a/docker-compose.yml b/docker-compose.yml index 19064d6..cf7492b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,11 @@ services: volumes: - config:/etc/gitlab-runner - /var/run/docker.sock:/var/run/docker.sock + crond: + build: + context: crond/ + volumes: + - /run/docker.sock:/run/docker.sock volumes: config: -- GitLab