<p>I have a <code>registry:2</code> deployed as pod in my kubernetes cluster (running on docker-for-win, WSL2). I have two services for this pod as shown below:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: registry-external
spec:
  type: NodePort
  selector:
    app: registry
  ports:
    - protocol: TCP
      port: 5000
      nodePort: 32020
---
apiVersion: v1
kind: Service
metadata:
  name: registry
spec:
  selector:
    app: registry
  ports:
    - name: http
      protocol: TCP
      port: 2100
      targetPort: 5000
</code></pre>
<p>So the first one for reaching the registry from outside the cluster (on port 32020, so I can <code>docker login localhost:32020</code> on the host machine) and one for reaching the registry from the inside (on port 2100).</p>
<p>The login from outside works just fine. I've verified by <code>nslookup registry</code> on the cluster, that the registry should be reachable on <code>registry.default.svc.cluster.local</code>. So I created my image pull secrets with</p>
<pre class="lang-json prettyprint-override"><code>{
    &quot;auths&quot;: {
        &quot;registry.default.svc.cluster.local:2100&quot;: {
            &quot;auth&quot;: &quot;......&quot;
        },
    ...
}
</code></pre>
<p>When I try to deploy a pod with this image pull secret and image <code>registry.default.svc.cluster.local:2100/animage:latest</code>
it fails with</p>
<pre><code>dial tcp: lookup registry.default.svc.cluster.local on 192.168.65.1:53: no such host
</code></pre>
<p>I'm puzzled by this: shouldn't the URL be valid at time of image pull?</p>

stefan
<p>The issue here is that the pull is executed in an environment where the kubernetes cluster DNS is not available, i.e. a cluster node, but not a cluster pod (in case of kubernetes on docker-for-win, it is executed on the same network as the host).</p>
<p>Since the registry is also exposed with a <code>NodePort</code> service, it can be reached on the <code>nodePort</code> port 32020 on localhost. Therefore, the image pull secret needs to be adjusted to</p>
<pre class="lang-json prettyprint-override"><code>{
    &quot;auths&quot;: {
        &quot;localhost:32020&quot;: {
            &quot;auth&quot;: &quot;......&quot;
        },
    ...
}
</code></pre>
<p>and the image to pull becomes <code>localhost:32020/animage:latest</code>.</p>
