我在我的机器上设置了一个自托管注册表来存储docker镜像文件,以便使用minikube(用于本地开发的轻量级Kubernetes实现)对其进行彻底测试。
虽然我能够使用docker push和docker pull命令从本地注册表成功推送和提取存储库,但在尝试在本地运行pod时,面临以下问题:
错误
Failed to pull image "localhost:5000/dev/customer:v1": rpc error: code = Unknown desc
= Error response from daemon: Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: getsockopt: connection refused
这是我在检查吊舱时发现的事件列表。
根据事件
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 16m default-scheduler Successfully assigned custappdeployment-6c8ddcc5d8-2zdfn to minikube
Normal SuccessfulMountVolume 16m kubelet, minikube MountVolume.SetUp succeeded for volume "default-token-s5nlw"
Normal BackOff 16m (x2 over 16m) kubelet, minikube Back-off pulling image "localhost:5000/dev/customer:v1"
Warning Failed 16m (x2 over 16m) kubelet, minikube Error: ImagePullBackOff
Normal Pulling 15m (x3 over 16m) kubelet, minikube pulling image "localhost:5000/dev/customer:v1"
Warning Failed 15m (x3 over 16m) kubelet, minikube Failed to pull image "localhost:5000/dev/customer:v1": rpc error: code = Unknown desc
= Error response from daemon: Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: getsockopt: connection refused
Warning Failed 15m (x3 over 16m) kubelet, minikube **Error: ErrImagePull**
Please see below the docker pull command output.
PS C:\Sunny\Projects\NodeApps\Nodejs-Apps\Customer> docker pull localhost:5000/dev/customer:v1
v1: Pulling from dev/customer
Digest: sha256:edf0b716728b1cc00f7d8eed76fb3bdceadf1a60a46b9e4f80d983a64389e95c
Status: Image is up to date for localhost:5000/dev/customer:v1
好吧,我不希望你的localhost
与localhost
的观点中的minikube
相同。实际上,我不希望你的localhost与kubernetes世界中的任何东西都是同一个本地主机。
所以,你需要检查一些实用的东西:
你可以随时作弊,因为minikube是一个虚拟机(而不是一整套节点)和docker save $the_image_ref | minikube ssh docker load
将完全支持拉力(除非你有imagePullPolicy: Always
但很容易修复)。
如果您使用私有docker注册表,请将注册表绑定到0.0.0.0
,以便可以从其他服务器访问它。此外,如果其不安全的注册表,请将此URL添加到docker守护程序不安全的注册表列表中。