Answers: <p>Are you sure that your registry is publicly available?
  Checklist:</p>
  <ul>
  <li>Check if the domain is reachable and responding the right IP address -- <code>nslookup myregistry</code></li>
  <li>Check if your port is open or not blocked any kind of software (let's say via firewalls or AWS security group) -- <code>telnet myregistry 5050</code></li>
  <li>Check if your registry is not restricted for a particular CIDR of IP</li>
  <li>Test your login locally and ensure that there is no problem with it</li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2020-07-22T09:01:01.810Z
Answers: 2020-07-22T09:01:01.810Z
Answers: Hakob
Body: <p>I have GitLab server and a separate <code>docker-registry</code>. I have created a <code>testuser</code> with a <code>testpassword</code>.</p>
  <p>My  <code>.gitlab-ci.yml</code></p>
  <pre><code>image: docker:latest
  services:
    - docker:18.09.7-dind
      
  variables:
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
      # See https://github.com/docker-library/docker/pull/166
    DOCKER_TLS_CERTDIR: &quot;&quot;
    REGISTRY: myregistry:5000/golang-test
  
  stages:
    - build
   # - test
  before_script:
    - docker login -u testuser -p testpassword  myregistry:5000
  
  build_project:
      stage: build
      tags:
        - docker-ci
      script:
        - docker ps
        - docker build -t $REGISTRY .
        - docker push $REGISTRY
  
  </code></pre>
  <p>When CI pipeline runs, I get following error.</p>
  <blockquote>
  <p>WARNING! Using --password via the CLI is insecure. Use
  --password-stdin. Error response from daemon: Get https://myregistry:5000/v2/: dial tcp: lookup worker1 on
  192.168.123.456:53: no such host ERROR: Job failed: exit code 1</p>
  </blockquote>
  <pre><code>concurrent = 1
  check_interval = 0
  
  [session_server]
    session_timeout = 1800
  
  [[runners]]
    name = &quot;docker-ci&quot;
    url = &quot;https://gitlab.sample.com:8000/&quot;
    token = &quot;89MfxRTby83ny3eTkTf2&quot;
    tls-ca-file = &quot;/etc/gitlab-runner/certs/gitlab.sample.com.crt&quot;
    executor = &quot;docker&quot;
    pre_build_script = &quot;export DOCKER_HOST=tcp://docker:2375&quot;
    [runners.custom_build_dir]
    [runners.cache]
      [runners.cache.s3]
      [runners.cache.gcs]
    [runners.docker]
      tls_verify = false
      image = &quot;ubuntu:18.04&quot;
      privileged = true
      disable_entrypoint_overwrite = false
      oom_kill_disable = false
      disable_cache = false
      volumes = [&quot;/cache&quot;]
      shm_size = 0
  </code></pre>
  <p>This was after suggested modifications <a href="https://devops.stackexchange.com/questions/9359/gitlab-ci-error-during-connect-get-http-docker2375-v1-40-containers-jsonall">here</a>.</p>
  <p>I can successfully login to my <code>docker-registry</code> using <code>docker login -u testuser -p testpassword  https://myregistry:5000</code> from gitlab running server.</p>
  
Tags: <docker><continuous-integration><gitlab><gitlab-ci-runner>
Title: Gitlab CI push to docker-registry fails
UserDisplayName: Sachith Muhandiram
ThreadText: # Gitlab CI push to docker-registry fails
  
  (Asked by: username_0 on 2020-07-02)
  
  I have GitLab server and a separate `docker-registry`. I have created a `testuser` with a `testpassword`.
  
  My `.gitlab-ci.yml`
  
  ```
  image: docker:latest
  services:
    - docker:18.09.7-dind
      
  variables:
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
      # See https://github.com/docker-library/docker/pull/166
    DOCKER_TLS_CERTDIR: ""
    REGISTRY: myregistry:5000/golang-test
  
  stages:
    - build
   # - test
  before_script:
    - docker login -u testuser -p testpassword  myregistry:5000
  
  build_project:
      stage: build
      tags:
        - docker-ci
      script:
        - docker ps
        - docker build -t $REGISTRY .
        - docker push $REGISTRY
  
  ```
  
  When CI pipeline runs, I get following error.
  
  > WARNING! Using --password via the CLI is insecure. Use
  > --password-stdin. Error response from daemon: Get https://myregistry:5000/v2/: dial tcp: lookup worker1 on
  > 192.168.123.456:53: no such host ERROR: Job failed: exit code 1
  
  ```
  concurrent = 1
  check_interval = 0
  
  [session_server]
    session_timeout = 1800
  
  [[runners]]
    name = "docker-ci"
    url = "https://gitlab.sample.com:8000/"
    token = "89MfxRTby83ny3eTkTf2"
    tls-ca-file = "/etc/gitlab-runner/certs/gitlab.sample.com.crt"
    executor = "docker"
    pre_build_script = "export DOCKER_HOST=tcp://docker:2375"
    [runners.custom_build_dir]
    [runners.cache]
      [runners.cache.s3]
      [runners.cache.gcs]
    [runners.docker]
      tls_verify = false
      image = "ubuntu:18.04"
      privileged = true
      disable_entrypoint_overwrite = false
      oom_kill_disable = false
      disable_cache = false
      volumes = ["/cache"]
      shm_size = 0
  
  ```
  
  This was after suggested modifications [here](https://devops.stackexchange.com/questions/9359/gitlab-ci-error-during-connect-get-http-docker2375-v1-40-containers-jsonall).
  
  I can successfully login to my `docker-registry` using `docker login -u testuser -p testpassword https://myregistry:5000` from gitlab running server.
  
  **Tags:** docker, continuous-integration, gitlab, gitlab-ci-runner
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-07-22. Score: 3
  
  Are you sure that your registry is publicly available?
  Checklist:
  
  * Check if the domain is reachable and responding the right IP address -- `nslookup myregistry`
  * Check if your port is open or not blocked any kind of software (let's say via firewalls or AWS security group) -- `telnet myregistry 5050`
  * Check if your registry is not restricted for a particular CIDR of IP
  * Test your login locally and ensure that there is no problem with it
  
  
  ---
  
  