Code-Quality template does not remove temporary containers after job when using dedicated gitlab-runner without docker-in-docker
Summary
When using a dedicated gitlab-runner according to the instructions given in the documentation at https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#set-up-a-private-runner-for-code-quality-without-docker-in-docker containers in "Exited" state are left behind and accumulate on the host where that runner was set up.
This seems to be because the Code-Quality.gitlab-ci.yml
template does not include --rm
option to the docker run
here: https://gitlab.com/gitlab-org/gitlab/-/blob/ae94bd4643b98e9506ed1d974530c9f3877ad40c/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml#L30
Steps to reproduce
- Set up Code-Quality in
.gitlab-ci
and set up a dedicated runner without docker-in-docker as per instructions in https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#set-up-a-private-runner-for-code-quality-without-docker-in-docker - Run some pipelines with the code-quality job enabled
- Look at
docker ps -a
on the host where the gitlab-runner was set up.
Example Project
This cannot be reproduced on gitlab.com shared runners since this only affects installations which manage their runners themselves.
Also, investigation necessitates access to docker on the host where the runner is set up.
What is the current bug behavior?
Code quality containers accumulate on the host where the gitlab-runner was set up.
What is the expected correct behavior?
Code quality container is automatically removed after the job concludes.
Relevant logs and/or screenshots
docker ps -a
output provided below.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
084be7c02677 codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 4 hours ago Exited (0) 4 hours ago admiring_robinson
72405a10b0ba codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 4 hours ago Exited (0) 4 hours ago xenodochial_allen
e2fadce33748 codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 4 hours ago Exited (0) 4 hours ago friendly_bell
0c75a7a73937 codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 4 hours ago Exited (0) 4 hours ago beautiful_taussig
c0eafc4976c6 registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.24 "/run.sh /code" 4 hours ago Exited (0) 4 hours ago festive_panini
d9dcf39d5454 registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.24 "/run.sh /code" 4 hours ago Exited (0) 4 hours ago admiring_hodgkin
9f16774e892c codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 4 hours ago Exited (0) 4 hours ago nervous_chebyshev
d251f7506c42 codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 4 hours ago Exited (0) 4 hours ago busy_fermat
b94addc6c250 codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 4 hours ago Exited (0) 4 hours ago awesome_hermann
664da8eae2f1 codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 4 hours ago Exited (0) 4 hours ago busy_gagarin
fe814773e324 registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.24 "/run.sh /code" 4 hours ago Exited (0) 4 hours ago jolly_dewdney
4254b35eb666 registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.24 "/run.sh /code" 4 hours ago Exited (0) 4 hours ago interesting_williams
e6dbae60347e codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 24 hours ago Exited (0) 24 hours ago bold_einstein
7ad0acd31a50 codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 24 hours ago Exited (0) 24 hours ago sad_mayer
982f5be9eac6 codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 24 hours ago Exited (0) 24 hours ago modest_mclaren
d7d26e80649c codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 24 hours ago Exited (0) 24 hours ago mystifying_wu
2091a886ed2c registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.24 "/run.sh /code" 24 hours ago Exited (0) 24 hours ago strange_brahmagupta
d0e3886b49e5 registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.24 "/run.sh /code" 24 hours ago Exited (0) 24 hours ago priceless_shockley
6e9123736f0f codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 25 hours ago Exited (0) 25 hours ago dazzling_colden
a7cd2b3882ed codeclimate/codeclimate:0.85.24 "/usr/src/app/bin/co…" 25 hours ago Exited (0) 25 hours ago naughty_bartik
59acc07f6d42 registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.24 "/run.sh /code" 25 hours ago Exited (0) 25 hours ago festive_knuth
Output of checks
Results of GitLab environment info
Using GitLab 14.0.5, with gitlab-runner 14.0.1. Self-hosted, EE core tier.
Results of GitLab application Check
N/A (Not a GitLab application issue).
Possible fixes
--rm
option to the docker run
here: https://gitlab.com/gitlab-org/gitlab/-/blob/ae94bd4643b98e9506ed1d974530c9f3877ad40c/lib/gitlab/ci/templates/Jobs/Code-Quality.gitlab-ci.yml#L30