<p>I have followed successfully this tutorial in order to create a private docker registry hosted in Kubernetes:
<a href="https://www.knowledgehut.com/blog/devops/private-docker-registry" rel="nofollow noreferrer">https://www.knowledgehut.com/blog/devops/private-docker-registry</a></p>
<p>I've called my private registry <code>registro</code>, and the IP address of the service is: 10.43.48.208</p>
<p>With kaniko, I've gathered to push an <code>alpine</code> image to my registry in other to test.</p>
<p>I've created a secret in order to authenticate with the registry:</p>
<pre><code>kubectl create secret generic cred-reg \
    --from-file=.dockerconfigjson=./config.json \
    --type=kubernetes.io/dockerconfigjson
</code></pre>
<p>Then:</p>
<pre><code>kubectl edit serviceaccounts default
</code></pre>
<p>and added:</p>
<pre><code>imagePullSecrets:
- name: cred-reg
</code></pre>
<p>Now I want to use that image in a pod.</p>
<pre><code>kubectl run -ti --rm -q test --image=registro:5000/alpine
</code></pre>
<p>The result is this:</p>
<pre><code>Failed to pull image &quot;registro:5000/alpine&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;registro:5000/alpine:latest&quot;: failed to resolve reference &quot;registro:5000/alpine:latest&quot;: failed to do request: Head &quot;https://registro:5000/v2/alpine/manifests/latest&quot;: dial tcp: lookup registro on 127.0.0.53:53: server misbehaving
</code></pre>
<p>It also fails:</p>
<pre><code>kubectl run -ti --rm -q test --image=registro:5000/alpine --overrides='{ &quot;spec&quot;: { &quot;template&quot;: { &quot;spec&quot;: { &quot;imagePullSecrets&quot;: [{&quot;name&quot;: &quot;cred-reg&quot;}] } } } }'
</code></pre>
<p>How can I avoid this error?</p>
<p>What is the IP address <code>127.0.0.53</code> about?</p>
<p><code>registro:5000</code> is using a self-signed certificate.
How do I configure the Kubernetes cluster to accept this certificate?</p>
<p>Related questions:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/56366046/kubernetes-not-pulling-image-from-private-registry">Kubernetes not pulling image from private registry</a></li>
</ul>
<p><strong>UPDATE 1</strong>:</p>
<p>With:</p>
<pre><code>kubectl port-forward svc/registro 5000:5000
</code></pre>
<p>and placed this line in my <code>/etc/hosts</code>:</p>
<pre><code>127.0.0.1 registro
</code></pre>
<p>and copy my self-signed certificate to: <code>/etc/docker/certs.d/registro:5000/ca.crt</code>, I can do successfully:</p>
<pre><code>$ docker login https://registro:5000
$ docker run -ti --rm registro:5000/alpine
</code></pre>
<p>but I can't still access from kubernetes:</p>
<pre><code>Failed to pull image &quot;registro:5000/alpine&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;registro:5000/alpine:latest&quot;: failed to resolve reference &quot;registro:5000/alpine:latest&quot;: failed to do request: Head &quot;https://registro:5000/v2/alpine/manifests/latest&quot;: EOF
</code></pre>
<p>I've tried with <code>curl</code> and it does work:</p>
<pre><code>curl https://registro:5000/v2/alpine/manifests/latest -u myuser:mypassword
</code></pre>

david.perez
Looks like a <strong>DNS issue preventing image pull</strong>. To have a successful connection, <strong>you must always meet DNS, routing and firewall requirements</strong>. </p>If the cluster's nodes do not have external IP addresses themselves, which is the case of a private cluster, you will need to enable private access on the subnet used by the cluster. &nbsp;</p>You can enable private access explicitly; or if you configure certain resources without external IP addresses to create outbound connections to the internet (used for internet egress), we can turn private access implicitly.</p>
