镜像不 找到
错误信息
错误: 镜像 devops/app:v2 不找到
快速摘要
Kubernetes or Docker cannot 查找 specified 镜像, 通常因为它 做不 exist, 是 in 错误 registry, or 认证是 missing.
为什么发生
镜像 name or 标签是 misspelled
镜像有 不是 构建 and pushed 到 registry
registry URL 是不正确 or 镜像是 in 不同 registry
Missing registry credentials — cluster cannot authenticate 到拉取镜像
最小示例
spec:
containers:
- name: app
image: myapp:v2 # image v2 was never pushedspec:
containers:
- name: app
image: myapp:v1 # use the existing versionbroken code 引用镜像 version 那个是 从不 pushed. fix uses version 那个 exists in registry.
如何诊断
验证镜像 name and 标签使用
docker 镜像or 检查 registry检查如果镜像 exists in registry:
docker 拉取 <镜像>验证 imagePullPolicy and 镜像引用 in 你的 Kubernetes manifest
检查 for ImagePullSecrets 如果 using 私有 registry
如何修复
正确镜像 name and 标签 in 你的部署 manifest
构建 and 推送镜像:
docker 构建 -t <镜像> . && docker 推送 <镜像>创建 imagePullSecret for 私有 registries and 引用它 in Pod spec
Ensure registry URL 是正确 (e.g., registry.示例.com/myapp:v1)
如何预防
Use CI 流水线到 automatically 构建 and 推送镜像 on 每个提交
Use explicit version 标签相反的
latest到 avoid ambiguity设置 imagePullSecrets for 私有 registries in 你的命名空间