Gitlab-runner std

root@storage:/srv#    docker run -d --name gitlab-runner --restart always \
>      -v /srv/gitlab-runner/config:/etc/gitlab-runner \
>      -v /var/run/docker.sock:/var/run/docker.sock \
>      gitlab/gitlab-runner:latest
0ef3869a2a8394069cb00297b8004125b1c34ef9854a4326a40bc9225b0f438e
root@storage:/srv# docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=8 revision=54944146 version=13.10.0
Running in system-mode.
 
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.oowy.fr
Enter the registration token:
drJDdsg2Px3LdBXNK29d
Enter a description for the runner:
[0fbcd90e5f3a]: gitlab-runner
Enter tags for the runner (comma-separated):
 
Registering runner... succeeded                     runner=drJDdsg2
Enter an executor: virtualbox, docker+machine, docker-ssh+machine, kubernetes, custom, docker, docker-ssh, parallels, shell, ssh:
docker
 
Enter the default Docker image (for example, ruby:2.6):
ruby:2.6
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

Gitlab-runner docker

# docker run -d --name gitlab-docker --restart always \
>       -v /srv/gitlab-docker/config:/etc/gitlab-runner \
>       -v /var/run/docker.sock:/var/run/docker.sock \
>       gitlab/gitlab-runner:latest
ee8195b8ddfc1aff042fcc4df8207ad332bb7049acfc98e7beb7aa44b64d06a5
# docker run --rm -it -v /srv/gitlab-docker/config:/etc/gitlab-runner gitlab/gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=7 revision=54944146 version=13.10.0
Running in system-mode.
 
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.oowy.fr
Enter the registration token:
drJDdsg2Px3LdBXNK29d
Enter a description for the runner:
[05a2d788c211]: gitlab-docker
Enter tags for the runner (comma-separated):
 
Registering runner... succeeded                     runner=drJDdsg2
Enter an executor: ssh, virtualbox, docker+machine, docker-ssh+machine, docker, docker-ssh, parallels, shell, kubernetes, custom:
docker
Enter the default Docker image (for example, ruby:2.6):
docker:stable
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
# docker ps -a
CONTAINER ID   IMAGE                         COMMAND                  CREATED              STATUS              PORTS     NAMES
ee8195b8ddfc   gitlab/gitlab-runner:latest   "/usr/bin/dumb-init …"   About a minute ago   Up About a minute             gitlab-docker
0ef3869a2a83   gitlab/gitlab-runner:latest   "/usr/bin/dumb-init …"   4 minutes ago        Up 4 minutes                  gitlab-runner
# nano /srv/gitlab-docker/config/config.toml
concurrent = 1
check_interval = 0
 
[session_server]
  session_timeout = 1800
 
[[runners]]
  name = "gitlab-docker"
  url = "https://gitlab.oowy.fr"
  token = "xAragCD5KRvmJysjYrFn"
  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 = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
    shm_size = 0
# docker restart gitlab-docker
gitlab-docker
# docker ps -a
CONTAINER ID   IMAGE                         COMMAND                  CREATED          STATUS          PORTS     NAMES
ee8195b8ddfc   gitlab/gitlab-runner:latest   "/usr/bin/dumb-init …"   17 minutes ago   Up 13 minutes             gitlab-docker
0ef3869a2a83   gitlab/gitlab-runner:latest   "/usr/bin/dumb-init …"   20 minutes ago   Up 20 minutes             gitlab-runner

Troubleshooting

Problem: In your GitLab CI jobs, you see this error message while trying to run some docker command:

error during connect: Post http://docker:2375/v1.40/auth: dial tcp: lookup docker on 192.168.178.1:53: no such host

Solution: This error occurs with docker-based gitlab runners such as the one we’re that are configured using a docker executor. The error message means that the inner docker container doesn’t have a connection to the host docker daemon.

In order to fix this, set these options in [runners.docker] in your gitlab-runner config.toml:

privileged = true
volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock"]

Why this works Adding “/var/run/docker.sock:/var/run/docker.sock” allows the inner docker container running inside the gitlab-runner to access the outer (host) docker daemon. Without this, it tries to connect to the docker default URL, i.e. http://docker:2375. This URL can’t be resolved via DNS (the DNS server in my case is 192.168.178.1, the DNS standard port being 53), hence docker prints the error message listed above.

Ce site web utilise des cookies. En utilisant le site Web, vous acceptez le stockage de cookies sur votre ordinateur. Vous reconnaissez également que vous avez lu et compris notre politique de confidentialité. Si vous n'êtes pas d'accord, quittez le site.En savoir plus