Docker for Windows Kubernetes pod gets ImagePullBackOff after creating a new deployment

12/17/2018

I have successfully built Docker images and ran them in a Docker swarm. When I attempt to build an image and run it with Docker Desktop's Kubernetes cluster:

docker build -t myimage -f myDockerFile .

(the above successfully creates an image in the docker local registry)

kubectl run myapp --image=myimage:latest

(as far as I understand, this is the same as using the kubectl create deployment command)

The above command successfully creates a deployment, but when it makes a pod, the pod status always shows:

NAME                                   READY  STATUS            RESTARTS  AGE 
myapp-<a random alphanumeric string>   0/1    ImagePullBackoff  0         <age>

I am not sure why it is having trouble pulling the image - does it maybe not know where the docker local images are?

-- JakeJ
docker
docker-for-windows
kubernetes

2 Answers

1/4/2019

I just had the exact same problem. Boils down to the imagePullPolicy:

PC:~$ kubectl explain deployment.spec.template.spec.containers.imagePullPolicy
KIND:     Deployment
VERSION:  extensions/v1beta1

FIELD:    imagePullPolicy <string>

DESCRIPTION:
     Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always
     if :latest tag is specified, or IfNotPresent otherwise. Cannot be updated.
     More info:
     https://kubernetes.io/docs/concepts/containers/images#updating-images

Specifically, the part that says: Defaults to Always if :latest tag is specified.

That means, you created a local image, but, because you use the :latest it will try to find it in whatever remote repository you configured (by default docker hub) rather than using your local. Simply change your command to:

kubectl run myapp --image=myimage:latest --image-pull-policy Never

or

kubectl run myapp --image=myimage:latest --image-pull-policy IfNotPresent
-- Lucas
Source: StackOverflow

12/17/2018

You didn't specify where myimage:latest is hosted, but essentially ImagePullBackoff means that I cannot pull the image because either:

  • You don't have networking setup in your Docker VM that can get to your Docker registry (Docker Hub?)
  • myimage:latest doesn't exist in your registry or is misspelled.
  • myimage:latest requires credentials (you are pulling from a private registry). You can take a look at this to configure container credentials in a Pod.
-- Rico
Source: StackOverflow