<p>I'm fighting with Kubernetes.  I've googled a lot and looked at a few answers such as <a href="https://stackoverflow.com/questions/40600419/why-am-i-getting-an-errimagepull-error-in-this-kubernetes-deployment">this one</a> - for example - but can't seem to get it to work.</p>

<p>I've created a docker container and push to local registry:</p>

<pre><code>sudo docker run -d -p 5000:5000 --name registry registry:2
sudo docker tag i-a/i-a:latest localhost:5000/i-a
sudo docker push localhost:5000/i-a
</code></pre>

<p>The last command gives:</p>

<pre><code>The push refers to a repository [localhost:5000/i-a]
e0a33c56cca0: Pushed 
54ab83ede54d: Pushed 
f5a58f369605: Pushed 
cd7100a72410: Pushed 
latest: digest: sha256:0f30cdf6b4a4e0e382a6cae50c1325103c3b987d9e51c42edea2244a82ae1331 size: 1164
</code></pre>

<p>Doing <code>sudo docker pull localhost:5000/i-a</code> gives:</p>

<pre><code>Using default tag: latest
latest: Pulling from i-a
Digest: sha256:0f30cdf6b4a4e0e382a6cae50c1325103c3b987d9e51c42edea2244a82ae1331
Status: Image is up to date for localhost:5000/i-a:latest
</code></pre>

<p>The config file i-a.yaml:</p>

<pre><code>---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    run: i-a
  name: i-a
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      run: i-a
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        run: i-a
    spec:
      containers:
      - image: localhost:5000/i-a
        imagePullPolicy: IfNotPresent
        name: i-a
        ports:
        - containerPort: 8090
      dnsPolicy: ClusterFirst
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    run: i-a
  name: i-a
  namespace: default
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8090
  selector:
    run: i-a
  sessionAffinity: None
  type: ClusterIP
</code></pre>

<p>When I do <code>sudo kubectl get pods --all-namespaces</code> I get:</p>

<pre><code>...
default       i-a-3400848339-0x6c9   0/1       ImagePullBackOff   0          13m
default       i-a-3400848339-7ltp1   0/1       ImagePullBackOff   0          13m
default       i-a-3400848339-wv092   0/1       ImagePullBackOff   0          13m
</code></pre>

<p>The <code>ImagePullBackOff</code> turns to <code>ErrImagePull</code>.</p>

<p>When I run <code>kubectl describe pod i-a-3400848339-0x6c9</code> I get an error <code>Failed to pull image "localhost:5000/i-a": Error while pulling image: Get http://localhost:5000/v1/repositories/i-a/images: dial tcp 127.0.0.1:5000: getsockopt: connection refused</code>:</p>

<pre><code>Name:       i-a-3400848339-0x6c9
Namespace:  default
Node:       minikube/192.168.99.100
Start Time: Mon, 09 Apr 2018 21:11:15 +0200
Labels:     pod-template-hash=3400848339
        run=i-a
Status:     Pending
IP:     172.17.0.7
Controllers:    ReplicaSet/i-a-3400848339
Containers:
  i-a:
    Container ID:                  
    Image:      localhost:5000/i-a
    Image ID:       
    Port:       8090/TCP
    State:      Waiting
      Reason:       ImagePullBackOff
    Ready:      False
    Restart Count:  0
    Volume Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-bmwkd (ro)
    Environment Variables:  &lt;none&gt;
Conditions:
  Type      Status
  Initialized   True 
  Ready     False 
  PodScheduled  True 
Volumes:
  default-token-bmwkd:
    Type:   Secret (a volume populated by a Secret)
    SecretName: default-token-bmwkd
QoS Class:  BestEffort
Tolerations:    &lt;none&gt;
Events:
  FirstSeen LastSeen    Count   From            SubobjectPath               Type        Reason      Message
  --------- --------    -----   ----            -------------               --------    ------      -------
  18m       18m     1   {default-scheduler }                        Normal      Scheduled   Successfully assigned i-a-3400848339-0x6c9 to minikube
  18m       2m      8   {kubelet minikube}  spec.containers{i-a}    Normal      Pulling     pulling image "localhost:5000/i-a"
  18m       2m      8   {kubelet minikube}  spec.containers{i-a}    Warning     Failed      Failed to pull image "localhost:5000/i-a": Error while pulling image: Get http://localhost:5000/v1/repositories/i-a/images: dial tcp 127.0.0.1:5000: getsockopt: connection refused
  18m       2m      8   {kubelet minikube}                      Warning     FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "i-a" with ErrImagePull: "Error while pulling image: Get http://localhost:5000/v1/repositories/i-a/images: dial tcp 127.0.0.1:5000: getsockopt: connection refused"

  18m   13s 75  {kubelet minikube}  spec.containers{i-a}    Normal  BackOff     Back-off pulling image "localhost:5000/i-a"
  18m   13s 75  {kubelet minikube}                      Warning FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "i-a" with ImagePullBackOff: "Back-off pulling image \"localhost:5000/i-a\""
</code></pre>

<p>I'm not sure where to look next...
(I get 404 when I browse to <a href="http://localhost:5000/v1/repositories/i-a/images" rel="nofollow noreferrer">http://localhost:5000/v1/repositories/i-a/images</a>)</p>

<p>Try with:</p>

<pre><code>spec:
      containers:
      - image: localhost:5000/i-a
        imagePullPolicy: Never
        name: i-a
        ports:
        - containerPort: 8090
      dnsPolicy: ClusterFirst
      restartPolicy: Always
</code></pre>
