2

I created a gitlab runner in GCP VM following a tutorial. But I'm getting the following error. enter image description here

.gitlab-ci.yml

stages:
  - ".pre"
  - lint
  - integration
image: node:stable
before_script:
  - apt-get update
  - npm install --progress=false
  - node -v
lint:
  stage: lint
  tags: 
    - test
  script:
    - npm run lint

docker ps shows that the container is running.

config.toml

concurrent = 1
check_interval = 0
[session_server]
  session_timeout = 1800
[[runners]]
  name = "gitlab-runner"
  url = "https://gitlab.com/"
  token = ""
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    tls_verify = false
    image = "docker:stable"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock","/cache"]
    shm_size = 0

I'm new to docker, can't find the error reason. Is there someone who can help me?

1 Answers1

3

Your gitlab runner user does not have permission to access unix:///var/run/docker.sock. By default, it uses gitlab-runner user too, so just add the user to docker group:

Run this command on the server that run the runner:

usermod -a -G docker gitlab-runner

If you are using another gitlab runner user, replace gitlab-runner with your user.

Truong Hua
  • 802
  • 6
  • 18
  • it says `usermod: user 'gitlab-runner' does not exist` but I run this `sudo usermod -aG docker $USER` now what? – A.S. SAMARASINGHE Nov 03 '21 at 12:34
  • @A.S.SAMARASINGHE If you are using Linux distro, do you have `/home/gitlab-runner` – Sachith Muhandiram Nov 03 '21 at 12:39
  • it says No such file or directory – A.S. SAMARASINGHE Nov 03 '21 at 12:47
  • Can you run `ps aux | grep gitlab-runner` and share the output. There should be a running process. – Truong Hua Nov 03 '21 at 16:23
  • `root 940 0.0 0.0 216 4 ? Ss Nov03 0:00 /usr/bin/dumb-init /entrypoint run --user=gitlab-runner --working-directory=/home/gitlab-runner root 954 0.0 0.8 152016 36104 ? Ssl Nov03 0:18 gitlab-runner run --user=gitlab-runner --working-directory=/home/gitlab-runner root 1817 0.0 0.9 152016 38920 ? Sl Nov03 0:18 /usr/bin/gitlab-runner run --working-directory /home/gitlab-runner --config /etc/gitlab-runner/config.toml --service gitlab-runner --syslog --user g itlab-runner` – A.S. SAMARASINGHE Nov 04 '21 at 04:43
  • Is the last one `--user gitlab-runner` instead of `--user g itlab-runner`. If so, it's using the default `gitlab-runner` user. If your system throw an error that `user 'gitlab-runner' does not exist`, can you check whether the user is existed in your `/etc/passwd` file. If not, I'm worry that your installation was not completed yet. Can you try to reinstall the gitlab-runner and carefully go through the documentation. – Truong Hua Nov 04 '21 at 09:52
  • yeah user is not there in the `/etc/passwd` – A.S. SAMARASINGHE Nov 04 '21 at 11:18
  • The installation scripts should be able to create that user. Did you install gitlab-runner from source code. Can you try to reinstall it again from gitlab prebuilt repos. – Truong Hua Nov 04 '21 at 11:56