gpt4 book ai didi

docker - 为什么在我使用Kubernetes时docker重新下载相同的镜像

转载 作者:行者123 更新时间:2023-12-02 11:58:34 28 4
gpt4 key购买 nike

我在没有Internet的隔离环境中使用kbuernetes和docker,我总是将镜像拉出并保存到其他计算机中的.tar文件中并加载到隔离环境中,但是有时kubernetes的Pod无法成功启动,并说Pod是拉镜像,但网络不正常。
但是我检查了docker的图像,该图像已加载,为什么我还需要再次拉相同的图像?

这是docker的镜像,已加载MYSQL的镜像:

[root@localhost kubecfg]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
quay.io/kubernetes-ingress-controller/nginx-ingress-controller 0.12.0 4a9cd8a2008a 3 weeks ago 230.5 MB
docker.io/mysql latest 5195076672a7 3 weeks ago 371.4 MB
gcr.io/google_containers/kube-apiserver-amd64 v1.9.2 7109112be2c7 11 weeks ago 210.4 MB

这是kubernetes的错误日志
[root@localhost kubecfg]# kubectl describe pod mysql-vmwdw
Name: mysql-vmwdw
Namespace: default
Node: localhost.localdomain/192.168.88.129
Start Time: Mon, 02 Apr 2018 14:14:07 +0800
Labels: app=mysql
Annotations: <none>
Status: Running
IP: 192.168.0.61
Controlled By: ReplicationController/mysql
Containers:
mysql:
Container ID: docker://9aa3128eaa1f330dfd0d6ebf732dca5a99ad49d7d6d4002a2384bdb03e056d7d
Image: docker.io/mysql
Image ID: docker-pullable://docker.io/mysql@sha256:691c55aabb3c4e3b89b953dd2f022f7ea845e5443954767d321d5f5fa394e28c
Port: 3306/TCP
State: Waiting
Reason: ImagePullBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Tue, 10 Apr 2018 14:56:04 +0800
Finished: Wed, 11 Apr 2018 08:56:04 +0800
Ready: False
Restart Count: 3
Environment:
MYSQL_ROOT_PASSWORD: 123456
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-s7kq2 (ro)
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
Volumes:
default-token-s7kq2:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-s7kq2
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulMountVolume 19m kubelet, localhost.localdomain MountVolume.SetUp succeeded for volume "default-token-s7kq2"
Normal SandboxChanged 19m (x12 over 19m) kubelet, localhost.localdomain Pod sandbox changed, it will be killed and re-created.
Warning FailedCreatePodSandBox 19m (x12 over 19m) kubelet, localhost.localdomain Failed create pod sandbox.
Warning Failed 9m (x6 over 18m) kubelet, localhost.localdomain Failed to pull image "docker.io/mysql": rpc error: code = Unknown desc = Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/mysql/images. You may want to check your internet connection or if you are behind a proxy.
Warning Failed 4m (x41 over 18m) kubelet, localhost.localdomain Error: ImagePullBackOff

它说: “无法提取图像” docker.io/mysql“:rpc错误:代码=未知desc =尝试连接到https://index.docker.io/v1/repositories/library/mysql/images时网络超时。您可能要检查Internet连接或是否在代理后面。”

我已经加载了图像,为什么 docker 会再次拉相同的图像?我该怎么做才能解决问题?

最佳答案

您正在使用:latest标签作为图像。当图像标签为latest时,kubernetes会将imagePullPolicy设置为Always。有关详细信息,请see the official doc

您可以将标签更改为其他名称(例如docker.io/mysql:8.0),或者只需将自己的imagePullPolicy指定为Never即可。

关于docker - 为什么在我使用Kubernetes时docker重新下载相同的镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49765160/

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