my-registry.example.com:5000/example/web-example:v1.0.1
1. 蓝色部分:registry 地址
2. 绿色部分:registry 端口
3. 紫色部分:repository 名字
4. 红色部分:image 名字
5. 棕色部分:image 标签
#更新镜像
如果您期望每次启动 Pod 时,都强制从镜像仓库抓取镜像,可以尝试如下方式:
- 设置 container 中的 imagePullPolicy 为 Always
- 省略 imagePullPolicy 字段,并使用 :latest tag 的镜像
- 省略 imagePullPolicy 字段和镜像的 tag
- 激活 AlwaysPullImages (opens new window)管理控制器
imagePullPolicy 字段和 image tag的可能取值将影响到 kubelet 如何抓取镜像:
- imagePullPolicy: IfNotPresent 仅在节点上没有该镜像时,从镜像仓库抓取
- imagePullPolicy: Always 每次启动 Pod 时,从镜像仓库抓取
- imagePullPolicy 未填写,镜像 tag 为 :latest 或者未填写,则同 Always 每次启动 Pod 时,从镜像仓库抓取
- imagePullPolicy 未填写,镜像 tag 已填写但不是 :latest,则同 IfNotPresent 仅在节点上没有该镜像时,从镜像仓库抓取
- imagePullPolicy: Never,Kubernetes 假设本地存在该镜像,并且不会尝试从镜像仓库抓取镜像
#使用私有仓库中的docker镜像
参数名称 | 参数值 | 备注 |
---|---|---|
registry地址 | my-registry.example.com | 推荐使用域名,也可以是 ip 地址 |
registry端口 | 5000 | 必须支持 HTTPS |
registry用户名 | myusername | |
registry密码 | mypassowrd | |
repository名字 | example | |
image名字 | web-example | |
image标签 | v1.0.1 |
docker login my-registry.example.com:5000
username: 提示 username 时,输入:myusername
password: 提示 password 时,输入:mypassword
docker pull my-registry.example.com:5000/example/web-example:v1.0.1
------========================================================================