liveBook · Manning

Image pull policy

As explained in Kubernetes in Action, Second Edition

An image pull policy is a Kubernetes container setting that determines when its container image is pulled onto a node.

An image pull policy determines when Kubernetes pulls a container image onto a worker node. It applies before a container starts and again whenever the container is restarted. section 6.4.1 section 6.4.2

Table 6.5 List of image-pull policies
Image-pull policy
Description
Not specified
If the imagePullPolicy is not explicitly specified, it defaults to Always if the :latest tag is used in the image. For other image tags, it defaults to IfNotPresent.
Always
The image is pulled every time the container is (re)started. If the locally cached image matches the one in the registry, it is not downloaded again, but the registry still needs to be contacted.
Never
The container image is never pulled from the registry. It must exist on the worker node beforehand. Either it was stored locally when another container with the same image was deployed, or it was built on the node itself, or simply downloaded by someone or something else.
IfNotPresent
Image is pulled if it is not already present on the worker node. This ensures that the image is only pulled the first time it’s required.

Compare the default behavior with Always, Never, and IfNotPresent. section 6.4.1

The policy controls the relationship between the registry and the image cached on the worker node:

  • Always contacts the registry and pulls the image on every container start or restart; an unchanged cached image need not be downloaded again. section 6.4.1
  • IfNotPresent pulls the image only when it is not already present on the worker node. section 6.4.1
  • Never skips the registry and requires the image to exist on the worker node beforehand. section 6.4.1
  • When unspecified, the policy defaults to Always for the latest tag and IfNotPresent for other image tags. section 6.4.1

A restart can trigger another pull

With imagePullPolicy set to Always, a failed container restart pulls the image again. If a corrected image is pushed under the same tag, the restart can obtain it without recreating the pod. However, an unavailable registry can prevent startup even when the same image is cached locally. section 6.4.1

Image pulling is part of each container’s independent startup sequence. A slow or failed pull can delay one container while other containers in the pod start; for init containers, each image is pulled before its ordered container runs. section 6.4.1 section 6.4.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains three policies, tag-based defaults, restart behavior, caching, and registry failures without descending into image internals.
Examples
Uses Always, Never, and IfNotPresent scenarios involving cached images, failed restarts, corrected tags, and unavailable registries.
What it assumes
Assumes basic familiarity with pods, containers, image tags, worker nodes, and image registries while defining policy behavior directly.
What you can do after
Operate/configure container startup by selecting a policy and anticipating its cache, restart, and registry effects.
How it connects
Connects image pull policy to container restarts, init containers, pod startup, worker nodes, image registries, and restart policies.

Also explained in

Compare how 2 books explain image pull policy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.