Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What the Two Statuses Mean

kubectl get pods
NAME                  READY   STATUS             RESTARTS   AGE
web-5f8c7d9b4-q7m2n   0/1     ImagePullBackOff   0          3m

The first failed pull shows as ErrImagePull. Kubernetes then waits before the next try, with a delay that grows each time up to five minutes, and shows ImagePullBackOff while it waits. After you fix the cause, the next attempt can take that long; deleting the pod makes its Deployment create a new one that tries at once.

Read the Events

kubectl describe pod web-5f8c7d9b4-q7m2n

The Events at the bottom contain a "Failed to pull image" line with the reason. The wording depends on the runtime and the registry, but it usually points to one of these:

Message mentionsUsual cause
not foundWrong name or tag
unauthorizedMissing credentials
access deniedNo rights, or no such repository
no such hostDNS on the node
i/o timeoutNetwork or firewall
no match for platformWrong CPU architecture
too many requestsPull limit reached

Wrong Name or Tag

Compare the image line of the manifest with what the registry holds: a typo, a tag that was never pushed, or uppercase letters are the usual finds. From a machine that is logged in to the registry:

docker buildx imagetools inspect registry.example.com/shop/web:1.4.0

If this fails as well, the name is wrong; see docker tag for how names are built. A name with invalid characters fails earlier, with InvalidImageName.

Private Registry: Add imagePullSecrets

The node needs credentials of its own. Log in once with docker login on an admin machine, using a read-only token, then turn that login into a secret in the pod's namespace:

kubectl create secret generic regcred -n shop \
  --from-file=.dockerconfigjson=$HOME/.docker/config.json \
  --type=kubernetes.io/dockerconfigjson

The file must hold the credentials itself. If it only names a credential helper, log in again with DOCKER_CONFIG set to an empty temporary folder, use the file created there, and delete the folder afterward. Then reference the secret in the pod template:

    spec:
      imagePullSecrets:
        - name: regcred
      containers:
        - name: web
          image: registry.example.com/shop/web:1.4.0

To cover every pod that uses a service account, add the secret to it instead:

kubectl patch serviceaccount default -n shop \
  -p '{"imagePullSecrets": [{"name": "regcred"}]}'

Network or DNS on the Node

The node pulls the image, not your computer. On the node:

getent hosts registry.example.com
curl -sI https://registry.example.com/v2/

Any HTTP answer, including 401, shows the registry is reachable. A failed lookup points to the node's resolver; a timeout points to a firewall on outbound port 443. A private CA must be trusted by the node's container runtime.

Test the Pull on the Node

sudo crictl pull nginx:alpine
sudo crictl images

crictl talks to the node's container runtime directly. On K3s, run it as sudo k3s crictl. If a public image pulls and yours does not, the path works and the problem is the name or the credentials. K3s can also hold registry mirrors and credentials per node in its registries.yaml; see K3s.

Wrong CPU Architecture

kubectl get nodes -L kubernetes.io/arch

If the nodes are arm64 and the image exists only for amd64, or the other way round, the pull fails. docker buildx imagetools inspect lists the platforms an image has. With a builder that supports multi-platform builds, build for both and push in one step:

docker buildx build --platform linux/amd64,linux/arm64 \
  -t registry.example.com/shop/web:1.4.0 --push .

Pull Limits and imagePullPolicy

The default registry limits anonymous pulls per IP address, and the nodes of a cluster often share one. Pull with credentials or through a registry mirror. imagePullPolicy decides when a node pulls at all:

  • Always: checks the registry on every container start. This is the default for the latest tag or no tag.
  • IfNotPresent: pulls only when the image is missing on the node; the default for other tags.
  • Never: uses only local images and fails with ErrImageNeverPull if the image is missing.

Version tags with IfNotPresent keep pulls to a minimum. More commands are in the kubectl cheat sheet; if the image pulls but the container keeps exiting, see CrashLoopBackOff.

Was this answer helpful?
Loading...