gpt4 book ai didi

docker - 如何在 Kubernetes 部署中引用从 tar 文件加载的本地 docker 镜像?

转载 作者:行者123 更新时间:2023-12-04 07:28:42 50 4
gpt4 key购买 nike

我正在尝试从本地 docker 镜像创建 Kubernetes 部署。并将 imagePullPolicy 设置为 Never,这样 Kubernetes 就会从通过 tar 导入的本地 docker 镜像中获取它。

环境

  • >
     SingleNodeMaster  # one node deployment

但 Kubernetes 总是尝试获取私有(private)存储库,尽管存在本地 docker 镜像。

关于如何调试和解决问题以便 Kubernetes 从本地 docker 注册表中选择图像的任何指示?谢谢。

执行的步骤

  • docker load -i images.tar
  • docker images # 显示来自 myprivatehub.com/nginx/nginx-custom:v1.1.8 的图像
  • kubectl create -f local-test.yaml with imagepullPolicy as Never

错误

Pulling  pod/nginx-custom-6499765dbc-2fts2   Pulling image "myprivatehub.com/nginx/nginx-custom:v1.1.8" 
Failed pod/nginx-custom-6499765dbc-2fts2 Error: ErrImagePull
Failed pod/nginx-custom-6499765dbc-2fts2 Failed to pull image "myprivatehub.com/nginx/nginx-custom:v1.1.8": rpc error: code = Unknown desc = failed to pull and unpack image "myprivatehub.com/nginx/nginx-custom:v1.1.8": failed to resolve reference "myprivatehub.com/nginx/nginx-custom:v1.1.8": failed to do request: Head "https://myprivatehub.com/v2/nginx/nginx-custom/manifests/v1.1.8": dial tcp: lookup myprivatehub.com: no such host
docker pull <imagename>

Error response from daemon: Get https://myprivatehub.com/v2/: dial tcp: lookup myprivatehub.com on 172.31.0.2:53: no such host
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-custom
namespace: default
spec:
selector:
matchLabels:
run: nginx-custom
replicas: 5
template:
metadata:
labels:
run: nginx-custom
spec:
containers:
- image: myprivatehub.com/nginx/nginx-custom:v1.1.8
imagePullPolicy: Never
name: nginx-custom
ports:
- containerPort: 80

最佳答案

这是因为容器运行时不同于 docker。我正在使用 containerd ,在将容器运行时切换到 docker 之后,它开始工作了。

关于docker - 如何在 Kubernetes 部署中引用从 tar 文件加载的本地 docker 镜像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68072772/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com