<p>I have an image in my docker repository. I an trying to create POD out of it but K8S is giving the following error. </p>

<p><em>Failed to pull image "cloudanswer:latest": rpc error: code = Unknown desc = Get <a href="https://registry-1.docker.io/v2/" rel="nofollow noreferrer">https://registry-1.docker.io/v2/</a>: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)</em></p>

<p>It seems K8S is connecting to <a href="https://registry-1.docker.io/v2/" rel="nofollow noreferrer">https://registry-1.docker.io/v2/</a> instead of taking from local docker repository.</p>

<p>How to make K8S take image for local docker repository ?</p>

Chandu
<p>If you use <strong>single node</strong> in your cluster, make sure this docker image is available on this node.
You can check via</p>

<pre><code>docker image ls
</code></pre>

<p>Also set the <code>imagePullPolicy</code> to <code>Never</code>, otherwise Kubernetes will try to download the image.</p>

<p><strong>Multiple node cluster</strong>, you can use docker <a href="https://hub.docker.com/_/registry" rel="nofollow noreferrer">registry image</a>.
Use a local registry:</p>

<pre><code>docker run -d -p 5000:5000 --restart=always --name registry registry:2
</code></pre>

<p>Now tag your image properly:</p>

<pre><code>docker tag ubuntu &lt;dns-name-of-machine&gt;:5000/ubuntu
</code></pre>

<p><strong>dns name</strong> of the machine running registry container should be reachable by all nodes in network</p>

<p>Now push your image to local registry:</p>

<pre><code>docker push &lt;dns-name-of-machine&gt;:5000/ubuntu
</code></pre>

<p>You should be able to pull it back:</p>

<pre><code>docker pull &lt;dns-name-of-machine&gt;:5000/ubuntu
</code></pre>

<p>Now change your yaml file to use local registry.</p>
