5.3. 镜像拉取(pull)策略

Pod 中的每个容器均有容器镜像。您创建了镜像并将其推送(push)到 registry 后,即可在 Pod 中引用它。

5.3.1. 镜像拉取(pull)策略概述

OpenShift Container Platform 在创建容器时,会使用容器的 imagePullPolicy 来决定是否应在启动容器前拉取(pull)镜像。imagePullPolicy 有三个可能的值:

表 5.3. imagePullPolicy

描述

Always

始终拉取(pull)镜像。

IfNotPresent

仅拉取(pull)节点上不存在的镜像。

Never

永不拉取(pull)镜像。

如果没有指定容器的 imagePullPolicy 参数,OpenShift Container Platform 会根据镜像标签来设置。

  1. 如果标签为 latest,OpenShift Container Platform 会将 imagePullPolicy 默认设置为 Always
  2. 否则,OpenShift Container Platform 会将 imagePullPolicy 默认设置为 IfNotPresent