Answers: <p>It seems your private DNS is misconfigured. Check your host or make sure that <code>docker-registry.default</code> is the a valid hostname.</p>
  <p>You can run a temporary Ubuntu pod to check if that hostname is resolving correctly from your cluster, e.g.</p>
  <pre><code>$ kubectl run ubuntu -it --image ubuntu --rm=true -- bash
  root@shell:/# apt update &amp;&amp; DEBIAN_FRONTEND=noninteractive apt --yes install dnsutils
  root@shell:/# dig docker-registry.default
  docker-registry.default.    IN  A D0.y0u.h4ve.1P?
  </code></pre>
  <p>Additional suggestions:</p>
  <ul>
  <li>If you're using a cloud provider (such as Azure), make sure your Private DNS zone is linked with your cluster's virtual network. Read: <a href="https://docs.microsoft.com/en-us/azure/container-registry/container-registry-private-link#create-a-docker-enabled-virtual-machine" rel="nofollow noreferrer">Connect privately to an Azure container registry using Azure Private Link</a></li>
  <li>If your container registry endpoint isn't correct, edit the deployment manifest and fix the image path.</li>
  <li>Test pulling the image from another VM within the same private network.</li>
  </ul>
  
Answers: CC BY-SA 4.0
Answers: 2020-09-11T13:45:19.013Z
Answers: 2020-09-11T13:50:29.507Z
Answers: 2020-09-11T13:50:29.507Z
Answers: kenorb
Body: <p>I have a private docker registry in k8 in the default namespace with <code>tls</code> at <code>https://docker-registry.default:5000</code>. By doing local port forwarding to it(at port 5000) and adding <code>docker-registry.default</code> to my <code>/etc/hosts</code> file, I have been able to pull and push images to it.</p>
  
  <p>However, I'm using a serverless framework(Nuclio) which manages the deploy for me. 
  The error I get is: </p>
  
  <pre><code>Normal   Scheduled  7m52s                   default-scheduler                                       Successfully assigned nuclio/helloworld1-96876fcf9-7c87w to gke-your-first-cluster-1-pool-1-fe915942-gnkx
    Normal   Pulling    6m14s (x4 over 7m51s)   kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Pulling image "docker-registry.default:5000/docker/nuclio/processor-helloworld1:latest"
    Warning  Failed     6m14s (x4 over 7m51s)   kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Failed to pull image "docker-registry.default:5000/docker/nuclio/processor-helloworld1:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://docker-registry.default:5000/v2/: dial tcp: lookup docker-registry.default on 169.254.169.254:53: no such host
    Warning  Failed     6m14s (x4 over 7m51s)   kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Error: ErrImagePull
    Normal   BackOff    6m2s (x6 over 7m51s)    kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Back-off pulling image "docker-registry.default:5000/docker/nuclio/processor-helloworld1:latest"
    Warning  Failed     2m38s (x21 over 7m51s)  kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Error: ImagePullBackOff
  </code></pre>
  
  <p>It gives a <code>no such host</code> error.</p>
  
  <p>A Nuclio developer has confirmed that it's not a nuclio issue since I cannot even do a <code>docker login</code> from the Nuclio Admin pod(not the failed pod above) to this internal <code>docker-registry.default</code> though I can do a <code>docker login</code> to the Docker hub and a <code>wget</code> to <code>docker-registry.default</code> successfully. The Nuclio Admin pod is Alpine Linux if it helps.</p>
  
Tags: <docker><kubernetes>
Title: No Such Host: Kubernetes/Docker cannot pull from private k8 registry
UserDisplayName: RAbraham
ThreadText: # No Such Host: Kubernetes/Docker cannot pull from private k8 registry
  
  (Asked by: username_0 on 2019-12-31)
  
  I have a private docker registry in k8 in the default namespace with `tls` at `https://docker-registry.default:5000`. By doing local port forwarding to it(at port 5000) and adding `docker-registry.default` to my `/etc/hosts` file, I have been able to pull and push images to it.
  
  However, I'm using a serverless framework(Nuclio) which manages the deploy for me.
  The error I get is:
  
  ```
  Normal   Scheduled  7m52s                   default-scheduler                                       Successfully assigned nuclio/helloworld1-96876fcf9-7c87w to gke-your-first-cluster-1-pool-1-fe915942-gnkx
    Normal   Pulling    6m14s (x4 over 7m51s)   kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Pulling image "docker-registry.default:5000/docker/nuclio/processor-helloworld1:latest"
    Warning  Failed     6m14s (x4 over 7m51s)   kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Failed to pull image "docker-registry.default:5000/docker/nuclio/processor-helloworld1:latest": rpc error: code = Unknown desc = Error response from daemon: Get https://docker-registry.default:5000/v2/: dial tcp: lookup docker-registry.default on 169.254.169.254:53: no such host
    Warning  Failed     6m14s (x4 over 7m51s)   kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Error: ErrImagePull
    Normal   BackOff    6m2s (x6 over 7m51s)    kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Back-off pulling image "docker-registry.default:5000/docker/nuclio/processor-helloworld1:latest"
    Warning  Failed     2m38s (x21 over 7m51s)  kubelet, gke-your-first-cluster-1-pool-1-fe915942-gnkx  Error: ImagePullBackOff
  
  ```
  
  It gives a `no such host` error.
  
  A Nuclio developer has confirmed that it's not a nuclio issue since I cannot even do a `docker login` from the Nuclio Admin pod(not the failed pod above) to this internal `docker-registry.default` though I can do a `docker login` to the Docker hub and a `wget` to `docker-registry.default` successfully. The Nuclio Admin pod is Alpine Linux if it helps.
  
  **Tags:** docker, kubernetes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-09-11. Score: 1
  
  It seems your private DNS is misconfigured. Check your host or make sure that `docker-registry.default` is the a valid hostname.
  
  You can run a temporary Ubuntu pod to check if that hostname is resolving correctly from your cluster, e.g.
  
  ```
  $ kubectl run ubuntu -it --image ubuntu --rm=true -- bash
  root@shell:/# apt update && DEBIAN_FRONTEND=noninteractive apt --yes install dnsutils
  root@shell:/# dig docker-registry.default
  docker-registry.default.    IN  A D0.y0u.h4ve.1P?
  
  ```
  
  Additional suggestions:
  
  * If you're using a cloud provider (such as Azure), make sure your Private DNS zone is linked with your cluster's virtual network. Read: [Connect privately to an Azure container registry using Azure Private Link](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-private-link#create-a-docker-enabled-virtual-machine)
  * If your container registry endpoint isn't correct, edit the deployment manifest and fix the image path.
  * Test pulling the image from another VM within the same private network.
  
  
  ---
  
  