Image pull policy
To manage image updates and optimize pod startup performance in OpenShift Container Platform, you can configure the imagePullPolicy parameter in your container specifications. This setting controls when container images are pulled from registries.
About the imagePullPolicy parameter
To control when OpenShift Container Platform pulls container images from registries or uses locally cached copies when starting containers, you can configure the imagePullPolicy parameter. This policy helps you manage image updates and optimize pod startup performance.
The following table lists the possible values for the imagePullPolicy parameter:
| Value | Description |
|---|---|
|
Always pull the image. |
|
Only pull the image if it does not already exist on the node. |
|
Never pull the image. |
The following example sets the imagePullPolicy parameter to IfNotPresent for the image tagged v1.2.3:
imagePullPolicy configurationapiVersion: apps/v1
kind: Deployment
# ...
spec:
# ...
template:
spec:
containers:
- name: my-app-container
image: registry.example.com/myapp:v1.2.3
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
where:
image-
Specifies is the image to use. In this example, the image tag is explicitly set to
v1.2.3. imagePullPolicy-
Specifies the policy to use. In this example, the policy is set to
IfNotPresentbecause the image tag is notlatest.
Omitting the imagePullPolicy parameter
When you omit the imagePullPolicy parameter, OpenShift Container Platform automatically determines the policy based on the image tag. This default behavior ensures that the latest tag always pulls the newest image, while specific version tags use locally cached images when available to improve efficiency.
| Image tag | imagePullPolicy setting |
Behavior |
|---|---|---|
|
|
Always pulls the image. This policy helps ensure that the container always uses the latest version of the image. |
Any other tag (for example, |
|
Pull only if necessary. This policy uses the locally cached version of the image if it exists on the node, avoiding unnecessary pulls from the registry. |