Home > database >  Difference between Always and IfNotPresent imagePullPolicy
Difference between Always and IfNotPresent imagePullPolicy

Time:10-10

I was checking Kubernetes documentation for pulling images. In that, I saw two policies IfNotPresent and Always. In "Always" its stated that

If the kubelet has a container image with that exact digest cached locally, the kubelet uses its cached image; otherwise, the kubelet pulls the image with the resolved digest, and uses that image to launch the container.

I am unable to understand what is local here. Is it a node, pod, or cluster? What is the difference between Always and IfNotPresent if it is at node level? It's very confusing.

CodePudding user response:

This refers to the cache of the node where that pod would be running. Each node has its own images cache.

If the image is present in cache, IfNotPresent policy would re-use it and skip image pull. While Always ensures to always pull the image.

CodePudding user response:

Always at the name suggests will cause the container runtime to attempt to pull a new version of the image from the repository every time it tries to create the container.

In docker, this is like doing:

docker run --pull=always nginx

IfNotPresent will pull the image if it does not exist on the node that is attempting to create the container

This is like doing:

docker run --pull=missing nginx

or

docker run nginx

  • Related