"kubectl get pods" showing STATUS - ImagePullbackOff

7/4/2018

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

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

Error

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

Here's the list of events I noticed while inspecting the pod.

Pod Events

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> 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
-- Sunny Goel
docker
docker-registry
kubernetes
minikube

2 Answers

7/4/2018

Well, I wouldn't expect your localhost to be the same as localhost from minikube's point-of-view. Actually, I wouldn't expect your localhost to be the same localhost from anything in the kubernetes world's point-of-view.

So, some practical things you'll want to check:

  • is port 5000 accessible from not-your-machine (meaning could the minikube virtual machine plausibly pull from port 5000 on your machine)

    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

  • can minikube resolve the hostname that your machine presents itself as (because I actually don't think 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

  • 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

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

-- mdaniel
Source: StackOverflow

7/4/2018

If you are using private docker registry, bind registry to 0.0.0.0 so it is accessible from other servers. Also if its insecure registry, add this URL to docker daemon insecure registries list.

-- Akash Sharma
Source: StackOverflow