Sub topic 9
ErrImagePull and ImagePullBackOff
This chapter assumes you can run kubectl get and kubectl describe, read a pod manifest, and know what an image, a registry, and a tag are. It also assumes you know that a pod's container can be in the Waiting state.
What the two statuses mean
Before a container starts, the kubelet (the agent on each node) must pull its image. If the pull fails, the container stays in the Waiting state with one of two reasons:
ErrImagePull: the pull just failed.ImagePullBackOff: the kubelet is waiting before it retries. The delay starts at 10 seconds and doubles on each failure, up to a cap of 5 minutes.
A pod usually shows ErrImagePull briefly, then alternates between the two. Both mean the same thing: the node could not get the image. The pod phase stays Pending, because no container has started.
Find the cause in the events
The status only says that the pull failed. The reason is in the pod's events.
kubectl get pod web
kubectl describe pod web | grep -A 12 'Events:'Look for the Failed event. Its message holds the registry's answer, and the wording points to the cause.
| Message contains | Likely cause |
|---|---|
| `not found`, `manifest unknown` | The tag or image name does not exist |
| `pull access denied`, `authorization failed`, `unauthorized` | Missing or wrong registry credentials, or the repository is private |
| `no such host`, `i/o timeout` | DNS or network path from the node to the registry |
| `toomanyrequests` | The registry is rate limiting you |
Check the image reference first
Most pull failures come from a typo. Print the exact image the pod uses:
kubectl get pod web -o jsonpath='{.spec.containers[*].image}'Check each part of the reference: registry host, repository path, and tag. A missing tag defaults to latest, which may not exist in your registry. A tag like 1.4.2 is not the same as v1.4.2.
Then confirm the image exists, from a machine that can reach the registry:
docker manifest inspect registry.example.com/team/web:1.4.2If it does, the problem is probably access from the node, not the name.
Fix and retry
You cannot edit most fields of a running pod, but you can change the image on a Deployment. The Deployment then creates new pods with the corrected reference:
kubectl set image deployment/web app=registry.example.com/team/web:1.4.2
kubectl rollout status deployment/webIf the cause was fixed outside the pod, such as a missing tag that is now pushed, you do not need to do anything. The next retry succeeds. You can speed this up by deleting the pod so its controller creates a new one.
Credential problems get their own treatment in the next chapter, along with imagePullSecrets.
Exercise
A pod shows ImagePullBackOff. The Events section says manifest unknown for registry.example.com/team/web:2.0. What is the most likely cause, and which command confirms the image reference the pod is using?
Show answer
The tag 2.0 does not exist in that repository, so the image name or tag is wrong, not the credentials. Run kubectl get pod web -o jsonpath='{.spec.containers[*].image}' to see the exact reference. Then check the registry for the correct tag and update the Deployment with kubectl set image.