<p>I setup a <strong>self-hosted</strong> registry on my machine to store the docker image files to test it thoroughly using <strong>minikube</strong> (lightweight Kubernetes implementation for local development).</p>

<p>Though I'm able to successfully push &amp; pull repositories from local registry using <strong>docker push</strong> and <strong>docker pull</strong> commands but while trying to run a pod locally, facing below issue :</p>

<p><strong>Error</strong> </p>

<pre><code>Failed to pull image "localhost:5000/dev/customer:v1": rpc error: code = Unknown desc
= Error response from daemon: Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: getsockopt: connection refused
</code></pre>

<p>Here's the list of events I noticed while inspecting the pod. </p>

<p><strong>Pod Events</strong></p>

<pre><code>Type     Reason                 Age                From               Message

----     ------                 ----               ----               -------

Normal   Scheduled              16m                default-scheduler  Successfully assigned custappdeployment-6c8ddcc5d8-2zdfn to minikube

Normal   SuccessfulMountVolume  16m                kubelet, minikube  MountVolume.SetUp succeeded for volume "default-token-s5nlw"

Normal   BackOff                16m (x2 over 16m)  kubelet, minikube  Back-off pulling image "localhost:5000/dev/customer:v1"

Warning  Failed                 16m (x2 over 16m)  kubelet, minikube  Error: ImagePullBackOff

Normal   Pulling                15m (x3 over 16m)  kubelet, minikube  pulling image "localhost:5000/dev/customer:v1"

Warning  Failed                 15m (x3 over 16m)  kubelet, minikube  Failed to pull image "localhost:5000/dev/customer:v1": rpc error: code = Unknown desc
= Error response from daemon: Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: getsockopt: connection refused

Warning  Failed                 15m (x3 over 16m)  kubelet, minikube  **Error: ErrImagePull**

Please see below the docker pull command output. 

PS C:\Sunny\Projects\NodeApps\Nodejs-Apps\Customer&gt; docker pull localhost:5000/dev/customer:v1

v1: Pulling from dev/customer
Digest: sha256:edf0b716728b1cc00f7d8eed76fb3bdceadf1a60a46b9e4f80d983a64389e95c
Status: Image is up to date for localhost:5000/dev/customer:v1
</code></pre>

<p>Well, I wouldn't expect <strong>your</strong> <code>localhost</code> to be the same as <code>localhost</code> from <code>minikube</code>'s point-of-view. Actually, I wouldn't expect your localhost to be the same localhost from <em>anything</em> in the kubernetes world's point-of-view.</p>

<p>So, some practical things you'll want to check:</p>

<ul>
<li><p>is port 5000 accessible from not-your-machine (meaning could the minikube virtual machine plausibly pull from port 5000 on your machine)</p>

<p>this question likely has some intersection with the point right below, because your registry may very well be listening on one of the internal adapters, but that's not what your machine knows itself as, or the opposite</p></li>
<li><p>can minikube resolve the hostname that your machine presents itself as (because I actually don't <em>think</em> you can use an IP address in a docker image reference); obviously if that assumption isn't true, then no need to worry about this part</p></li>
<li><p>and be sure that docker either is untrusting of your registry's CA, or you have already loaded the cert onto minikube and bounced docker</p></li>
</ul>

<p>You can always cheat, since minikube is one virtual machine (and not a whole fleet of Nodes) and <code>docker save $the_image_ref | minikube ssh docker load</code> which will side-step the pull entirely (unless you have <code>imagePullPolicy: Always</code> but that's easily fixed).</p>
