title: 127.0.0.1:5000: getsockopt: connection refused in Minikube
body: <p>Using minikube and docker on my local Ubuntu workstation I get the following error in the Minikube web UI:</p>
  
  <pre><code>Failed to pull image "localhost:5000/samples/myserver:snapshot-180717-213718-0199": 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>after I have created the below deployment config with:</p>
  
  <pre><code>kubectl apply -f hello-world-deployment.yaml
  </code></pre>
  
  <p><strong>hello-world-deployment.yaml</strong></p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: hello-world
  spec:
    replicas: 1
    template:
      metadata:
        labels:
          app: hello-world
          tier: backend
      spec:
        containers:
        - name: hello-world
          image: localhost:5000/samples/myserver:snapshot-180717-213718-0199
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
          env:
          - name: GET_HOSTS_FROM
            value: dns
          ports:
          - containerPort: 8080
  </code></pre>
  
  <p>And output from docker images:</p>
  
  <pre><code>REPOSITORY                                 TAG                           IMAGE ID            CREATED             SIZE
  samples/myserver                           latest                        aa0a1388cd88        About an hour ago   435MB
  samples/myserver                           snapshot-180717-213718-0199   aa0a1388cd88        About an hour ago   435MB
  k8s.gcr.io/kube-proxy-amd64                v1.10.0                       bfc21aadc7d3        3 months ago        97MB
  </code></pre>
  
  <p>Based on this guide:
  <a href="https://stackoverflow.com/questions/42564058/how-to-use-local-docker-images-with-minikube">How to use local docker images with Minikube?</a></p>
  
  <p>I have also run:</p>
  
  <pre><code>eval $(minikube docker-env)
  </code></pre>
  
  <p>and based on this:</p>
  
  <p><a href="https://github.com/docker/for-win/issues/624" rel="noreferrer">https://github.com/docker/for-win/issues/624</a></p>
  
  <p>I have added:</p>
  
  <pre><code>    "InsecureRegistry": [
          "localhost:5000",
          "127.0.0.1:5000"
      ],
  </code></pre>
  
  <p>to <code>/etc/docker/daemon.json</code></p>
  
  <p>Any suggestion on what I missing to get the image pull to work in minikube?</p>
  
  <p>I have followed the steps in the below answer but when I get to this step:</p>
  
  <pre><code>$ kubectl port-forward --namespace kube-system $(kubectl get po -n kube-system | grep kube-registry-v0 | awk '{print $1;}') 5000:5000
  </code></pre>
  
  <p>it just hangs like this:</p>
  
  <pre><code>$ kubectl port-forward --namespace kube-system $(kubectl get po -n kube-system | grep kube-registry-v0 | awk '{print $1;}') 5000:5000
  Forwarding from 127.0.0.1:5000 -&gt; 5000
  Forwarding from [::1]:5000 -&gt; 5000
  </code></pre>
  
  <p>and I get the same error in minikube dashboard after I create my deploymentconfig.</p>
  
  <p>Based on answer from <strong>BMitch</strong> I have now tried to create a local docker repository and push an image to it with:</p>
  
  <pre><code>$ docker run -d -p 5000:5000 --restart always --name registry registry:2
  $ docker pull ubuntu
  $ docker tag ubuntu localhost:5000/ubuntu:v1
  $ docker push localhost:5000/ubuntu:v1
  </code></pre>
  
  <p>Next when I do docker images I get:</p>
  
  <pre><code>$ docker images
  REPOSITORY                                      TAG                           IMAGE ID            CREATED             SIZE
  ubuntu                                          latest                        74f8760a2a8b        4 days ago          82.4MB
  localhost:5000/ubuntu                           v1                            74f8760a2a8b        4 days ago          82.4MB
  </code></pre>
  
  <p>I have then updated my deploymentconfig <strong>hello-world-deployment.yaml</strong> to:</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: hello-world
  spec:
    replicas: 1
    template:
      metadata:
        labels:
          app: hello-world
          tier: backend
      spec:
        containers:
        - name: hello-world
          image: localhost:5000/ubuntu:v1
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
          env:
          - name: GET_HOSTS_FROM
            value: dns
          ports:
          - containerPort: 8080
  </code></pre>
  
  <p>and </p>
  
  <pre><code>kubectl create -f hello-world-deployment.yaml
  </code></pre>
  
  <p>But in Minikube I still get similar error:</p>
  
  <pre><code> Failed to pull image "localhost:5000/ubuntu: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>So seems Minikube is not allowed to see the local registry I just created?</p>