<p>I am encountering a very basic error:</p>
<ol>
<li>I have docker-desktop and minikube setup on my windows 10 machine.</li>
<li>Further I setup a local docker registry using the steps <a href="https://docs.docker.com/registry/deploying/" rel="nofollow noreferrer">here</a>.
Here is what I have when I run <code>docker-ps</code> :</li>
</ol>
<pre><code>c:\&gt;docker ps
CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS              PORTS                                                                                                      NAMES
6675d2c57a74        registry:2                            &quot;/entrypoint.sh /etc…&quot;   7 hours ago         Up 2 hours          0.0.0.0:5000-&gt;5000/tcp                                                                                     registry
d05edc8f05b0        gcr.io/k8s-minikube/kicbase:v0.0.10   &quot;/usr/local/bin/entr…&quot;   8 hours ago         Up 8 hours          127.0.0.1:32771-&gt;22/tcp, 127.0.0.1:32770-&gt;2376/tcp, 127.0.0.1:32769-&gt;5000/tcp, 127.0.0.1:32768-&gt;8443/tcp   minikube
</code></pre>
<ol start="3">
<li>I pushed my local image to my local registry using <code>docker push</code>, and I deleted the local image using <code>docker image remove</code> command to avoid any confusion.</li>
<li>I now tried pulling the local registry image to see if it works, and it does</li>
</ol>
<pre><code>    docker pull localhost:5000/dev/my-web:v1

    v1: Pulling from dev/my-web
    Digest: sha256:b3a0cf5c66ade8d39709c0cbbd0e08c9cc5f5e1c97f039a2bd1afed657dc8b74
    Status: Downloaded newer image for localhost:5000/dev/my-web:v1
    localhost:5000/dev/my-web:v1
</code></pre>
<p>Now I run my kubectl create commands and they fail with the error <code>connection refused</code>.</p>
<pre class="lang-bsh prettyprint-override"><code>C:\&gt;kubectl create deployment myweb --image=localhost:5000/dev/my-web:v1
deployment.apps/myweb created

C:\&gt;kubectl get pods
NAME                        READY   STATUS         RESTARTS   AGE
myweb-7d467f4bc4-r9xhc   0/1     ErrImagePull   0          12s


C:\&gt;kubectl describe pod/myweb-7d467f4bc4-r9xhc
Name:         myweb-7d467f4bc4-r9xhc
Namespace:    default
Priority:     0
Node:         minikube/172.17.0.3
Start Time:   Sun, 09 Aug 2020 23:30:07 -0400
Labels:       app=myweb
              pod-template-hash=7d467f4bc4
Annotations:  &lt;none&gt;
Status:       Pending
IP:           172.18.0.3
IPs:
  IP:           172.18.0.3
Controlled By:  ReplicaSet/myweb-7d467f4bc4
Containers:
  my-web:
    Container ID:
    Image:          localhost:5000/dev/my-web:v1
    Image ID:
    Port:           &lt;none&gt;
    Host Port:      &lt;none&gt;
    State:          Waiting
      Reason:       ImagePullBackOff
    Ready:          False
    Restart Count:  0
    Environment:    &lt;none&gt;
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-nr7vj (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  default-token-nr7vj:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-nr7vj
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  93s                default-scheduler  Successfully assigned default/myweb-7d467f4bc4-r9xhc to minikube
  Normal   Pulling    53s (x3 over 92s)  kubelet, minikube  Pulling image &quot;localhost:5000/dev/my-web:v1&quot;
  Warning  Failed     53s (x3 over 92s)  kubelet, minikube  Failed to pull image &quot;localhost:5000/dev/my-web:v1&quot;: rpc error: code = Unknown desc = Error response from daemon: Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: connect: connection refused
  Warning  Failed     53s (x3 over 92s)  kubelet, minikube  Error: ErrImagePull
  Normal   BackOff    13s (x5 over 91s)  kubelet, minikube  Back-off pulling image &quot;localhost:5000/dev/my-web:v1&quot;
  Warning  Failed     13s (x5 over 91s)  kubelet, minikube  Error: ImagePullBackOff
  
</code></pre>
<p>I am not able to figure out why am I getting connection refused error when I am trying through <code>kubectl</code> command as against <code>docker pull</code> command.</p>
<p>Please help.</p>
<p><strong>Additional notes:</strong> (1) I am using in-built windows hypervisor (2) Using default networking</p>

<p>Well, Kubernetes cannot find your registry. It depends on the setup you have, but Docker for Windows runs in a VM and you didn't specify how you are running minikube, but most likely in another VM. So potentially here you have two VMs that can or cannot talk to each depending on how you set them up.</p>
<p>And <code>localhost</code> is almost never going to work with Kubernetes because that always resolves to the local IP of your Kubernetes node when it comes to pulling the image. That means that you would have to have your registry and the kubelet pulling the image on the exact same VM.</p>
<p>I would just focus on making it work with the VM IP address where your registry is running and make sure that your Kubernetes VM can reach the registry VM IP address. Also, remember that when you run your registry you also have to expose you container port in this case <code>5000</code></p>
<p>P.S. You didn't specify what Hypervisor you are running? VirtualBox? VMware? are you using bridged networking? host only❓</p>
<p>✌️</p>
