GitLab Runner “Runner has never contacted this instance”

I just installed and configured a GitLab Runner on a separate Ubuntu 22.04 server. Following tips here and here, I’ve started the runner with ‘sudo gitlab-runner start’ and I’ve verified the config with ‘sudo gitlab-runner verify’, but the GitLab server is still showing the ‘never contacted this instance’ error:

Following the troubleshooting steps here, I used journalctl to view the logs:

sudo journalctl --unit=gitlab-runner.service -n 100 --no-pager

and this gave me a clue:

Oct 19 14:36:24 proxmox-ubuntu2204-server systemd[1]: Started GitLab Runner.
Oct 19 14:36:25 proxmox-ubuntu2204-server gitlab-runner[1264]: FATAL: failed to get user home dir: $HOME is not defined
Oct 19 14:36:25 proxmox-ubuntu2204-server systemd[1]: gitlab-runner.service: Main process exited, code=exited, status=1/FAILURE
Oct 19 14:36:25 proxmox-ubuntu2204-server systemd[1]: gitlab-runner.service: Failed with result 'exit-code'.

To set a home dir for the gitlab-runner user, I checked /etc/passwd, found the line for gitlab-runner and it has an entry towards the end of the line for /home/gitlab-runner, so that seems ok.

Following tips here, I edited the service config with:

sudo systemctl edit gitlab-runner

which edits
/etc/systemd/system/gitlab-runner.service.d/override.conf and added this section:

[Service]
Environment="HOME=/home/gitlab-runner"

Restarted the service with:

sudo systemctl restart gitlab-runner

checked the logs again with jornalctl and now we’re up and running, and the runner is reported as available on the Runners page. Done!

Oct 19 14:51:48 proxmox-ubuntu2204-server gitlab-runner[1400]: Runtime platform                                    arch=amd64 os=linux pid=1400 revision=66a723c3 version=17.5.0
Oct 19 14:51:48 proxmox-ubuntu2204-server gitlab-runner[1400]: Starting multi-runner from /etc/gitlab-runner/config.toml... builds=0 max_builds=0
Oct 19 14:51:48 proxmox-ubuntu2204-server gitlab-runner[1400]: Running in system-mode.
Oct 19 14:51:48 proxmox-ubuntu2204-server gitlab-runner[1400]:
Oct 19 14:51:48 proxmox-ubuntu2204-server gitlab-runner[1400]: Configuration loaded builds=0 max_builds=1

Setting user prompted values during apt-get install (e.g. tzdata)

Installing php-fpm on Ubuntu 22:04 prompts for some timezone values during install which makes it more difficult to install during a ‘docker build’ since passing -y to apt-get-install is not enough to respond to the prompts.

Here’s what I’m prompted for if I just run ‘apt-get install php-fpm’:

Configuring tzdata
------------------

Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.

1. Africa 3. Antarctica 5. Arctic 7. Atlantic 9. Indian 11. US
2. America 4. Australia 6. Asia 8. Europe 10. Pacific 12. Etc
Geographic area: 8

Please select the city or region corresponding to your time zone.

1. Amsterdam 17. Guernsey 33. Monaco 49. Stockholm
2. Andorra 18. Helsinki 34. Moscow 50. Tallinn
3. Astrakhan 19. Isle_of_Man 35. Nicosia 51. Tirane
4. Athens 20. Istanbul 36. Oslo 52. Tiraspol
5. Belfast 21. Jersey 37. Paris 53. Ulyanovsk
6. Belgrade 22. Kaliningrad 38. Podgorica 54. Uzhgorod
7. Berlin 23. Kirov 39. Prague 55. Vaduz
8. Bratislava 24. Kyiv 40. Riga 56. Vatican
9. Brussels 25. Lisbon 41. Rome 57. Vienna
10. Bucharest 26. Ljubljana 42. Samara 58. Vilnius
11. Budapest 27. London 43. San_Marino 59. Volgograd
12. Busingen 28. Luxembourg 44. Sarajevo 60. Warsaw
13. Chisinau 29. Madrid 45. Saratov 61. Zagreb
14. Copenhagen 30. Malta 46. Simferopol 62. Zaporozhye
15. Dublin 31. Mariehamn 47. Skopje 63. Zurich
16. Gibraltar 32. Minsk 48. Sofia
Time zone: 27


Current default time zone: 'Europe/London'
Local time is now: Tue Sep 24 16:39:08 BST 2024.
Universal Time is now: Tue Sep 24 15:39:08 UTC 2024.
Run 'dpkg-reconfigure tzdata' if you wish to change it.

From answers on this post, the easiest option (rather than setting values for the prompted values) is to run in non-interactive mode, and just default the tz to UTC, with:

DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install php-fpm

Updating local versions of Docker images if using the latest tag

I have an ubuntu:latest image pulled locally from a couple of years ago, and it’s obviously not the latest since it’s over 2 years old. ‘docker images’ shows:

ubuntu                                                                           latest                     d5ca7a445605   2 years ago     65.6MB

If I run the image with -it and cat the /etc/lsb-release file, it shows it’s 20.04. Docker Hub is currently showing latest as 22.04.

To update it, if I ‘docker pull ubuntu:latest’ then it shows:

> docker pull ubuntu:latest
latest: Pulling from library/ubuntu
70104cd59e2a: Pull complete
Digest: sha256:1b8d8ff4777f36f19bfe73ee4df61e3a0b789caeff29caa019539ec7c9a57f95
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest

If I now start it and cat /etc/lsb-release, it shows 22.04. Done!