I have a private repo on gitlab.com. I have already setup a CI/CD pipeline using gitlab shared runners. On code push, a docker image is built, login to gitlab private docker registry and push the image. It works fine with the shared runners. Now I'm trying to create custom runners for the pipeline.

I've created a droplet on DigitalOcean (Docker 18.09.2~3 on Ubuntu 18.04 - 8 GB / 4 CPUs / 160 GB SSD)

ssh into the droplet

create a runner (from https://docs.gitlab.com/runner/install/docker.html#docker-image-installation-and-configuration)

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

and register it (from https://docs.gitlab.com/runner/register/index.html#one-line-registration-command)

docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register \
  --non-interactive \
  --executor "docker" \
  --docker-image alpine:3 \
  --url "https://gitlab.com/" \
  --registration-token "MY_TOKEN" \
  --description "docker-runner" \
  --tag-list "docker,digitalocean" \
  --run-untagged="true" \
  --locked="false"

on running the pipeline, it fails at this command

docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY

also if I use

docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com

with this error message

error during connect: Post http://docker:2375/v1.39/auth: dial tcp: lookup docker on 67.207.67.2:53: no such host
ERROR: Job failed: exit code 1

I also get the same error if I use my local PC.

I have tried editing /etc/hosts with no success.

It still works with the shared runners, but fails with my custom runners. What am I missing?

docker info

Containers: 4
 Running: 1
 Paused: 0
 Stopped: 3
Images: 4
Server Version: 18.09.2
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce
runc version: 09c8266bf2fcf9519a651b04ae54c967b9ab86ec
init version: fec3683
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.15.0-45-generic
Operating System: Ubuntu 18.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.79GiB
Name: docker-s-4vcpu-8gb-sgp1-01
ID: XF6Y:25TY:YXNO:RDHT:PEGU:KGR7:GPEM:DDBE:MAQ5:5VIJ:4GHB:Q7TF
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

this is the /etc/hosts file on the shared runner that processes the pipeline successfully

127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1   0hshit.hopto.org
127.0.0.1   daymndaymn.myftp.org
127.0.0.1   loba.webhop.me
172.17.0.3  docker 50d9e6c88489 runner-72989761-project-11958054-concurrent-0-docker-0
172.17.0.4  runner-72989761-project-11958054-concurrent-0

0 Answers