title: docker login in custom gitlab-runner: No such host (http://docker:2375/v1.39/auth: dial tcp: lookup docker on 172.31.0.2:53: no such host)
body: <p>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.</p>
  
  <p>I've created a droplet on DigitalOcean (Docker 18.09.2~3 on Ubuntu 18.04 - 8 GB / 4 CPUs / 160 GB SSD)</p>
  
  <p>ssh into the droplet</p>
  
  <p>create a runner (from <a href="https://docs.gitlab.com/runner/install/docker.html#docker-image-installation-and-configuration" rel="noreferrer">https://docs.gitlab.com/runner/install/docker.html#docker-image-installation-and-configuration</a>)</p>
  
  <pre><code>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
  </code></pre>
  
  <p>and register it (from <a href="https://docs.gitlab.com/runner/register/index.html#one-line-registration-command" rel="noreferrer">https://docs.gitlab.com/runner/register/index.html#one-line-registration-command</a>)</p>
  
  <pre><code>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"
  </code></pre>
  
  <p>on running the pipeline, it fails at this command</p>
  
  <pre><code>docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
  </code></pre>
  
  <p>also if I use</p>
  
  <pre><code>docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com 
  </code></pre>
  
  <p>with this error message</p>
  
  <pre><code>error during connect: Post http://docker:2375/v1.39/auth: dial tcp: lookup docker on 67.207.67.2:53: no such host
  </code></pre>
  
  <p>I also get the same error if I use my local PC.</p>
  
  <p>I have tried editing /etc/hosts with no success.</p>
  
  <p>It still works with the shared runners, but fails with my custom runners. What am I missing?</p>
  
  <p>docker info</p>
  
  <pre><code>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
  </code></pre>
  
  <p>this is the /etc/hosts file on the shared runner that processes the pipeline successfully</p>
  
  <pre><code>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 
  </code></pre>