我遇到一个非常基本的错误:
这是我运行
docker-ps
时所拥有的:c:\>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6675d2c57a74 registry:2 "/entrypoint.sh /etc…" 7 hours ago Up 2 hours 0.0.0.0:5000->5000/tcp registry
d05edc8f05b0 gcr.io/k8s-minikube/kicbase:v0.0.10 "/usr/local/bin/entr…" 8 hours ago Up 8 hours 127.0.0.1:32771->22/tcp, 127.0.0.1:32770->2376/tcp, 127.0.0.1:32769->5000/tcp, 127.0.0.1:32768->8443/tcp minikube
docker push
将本地镜像推送到本地注册表,并使用docker image remove
命令删除了本地镜像,以避免任何混乱。 docker pull localhost:5000/dev/my-web:v1
v1: Pulling from dev/my-web
Digest: sha256:b3a0cf5c66ade8d39709c0cbbd0e08c9cc5f5e1c97f039a2bd1afed657dc8b74
Status: Downloaded newer image for localhost:5000/dev/my-web:v1
localhost:5000/dev/my-web:v1
现在,我运行kubectl create命令,但它们失败,并显示错误connection refused
。C:\>kubectl create deployment myweb --image=localhost:5000/dev/my-web:v1
deployment.apps/myweb created
C:\>kubectl get pods
NAME READY STATUS RESTARTS AGE
myweb-7d467f4bc4-r9xhc 0/1 ErrImagePull 0 12s
C:\>kubectl describe pod/myweb-7d467f4bc4-r9xhc
Name: myweb-7d467f4bc4-r9xhc
Namespace: default
Priority: 0
Node: minikube/172.17.0.3
Start Time: Sun, 09 Aug 2020 23:30:07 -0400
Labels: app=myweb
pod-template-hash=7d467f4bc4
Annotations: <none>
Status: Pending
IP: 172.18.0.3
IPs:
IP: 172.18.0.3
Controlled By: ReplicaSet/myweb-7d467f4bc4
Containers:
my-web:
Container ID:
Image: localhost:5000/dev/my-web:v1
Image ID:
Port: <none>
Host Port: <none>
State: Waiting
Reason: ImagePullBackOff
Ready: False
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-nr7vj (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-nr7vj:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-nr7vj
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 Scheduled 93s default-scheduler Successfully assigned default/myweb-7d467f4bc4-r9xhc to minikube
Normal Pulling 53s (x3 over 92s) kubelet, minikube Pulling image "localhost:5000/dev/my-web:v1"
Warning Failed 53s (x3 over 92s) kubelet, minikube Failed to pull image "localhost:5000/dev/my-web:v1": rpc error: code = Unknown desc = Error response from daemon: Get http://localhost:5000/v2/: dial tcp 127.0.0.1:5000: connect: connection refused
Warning Failed 53s (x3 over 92s) kubelet, minikube Error: ErrImagePull
Normal BackOff 13s (x5 over 91s) kubelet, minikube Back-off pulling image "localhost:5000/dev/my-web:v1"
Warning Failed 13s (x5 over 91s) kubelet, minikube Error: ImagePullBackOff
我无法确定为什么我尝试通过kubectl
命令而不是docker pull
命令时出现连接被拒绝的错误。请帮忙。
其他说明:(1)我正在使用内置的Windows虚拟机管理程序(2)使用默认网络
最佳答案
好吧,Kubernetes找不到您的注册表。这取决于您的设置,但是适用于Windows的Docker在VM中运行,并且您未指定如何运行minikube,但很可能在另一VM中运行。因此,根据您的设置方式,这里可能有两个VM,每个VM可以或不能互相通信。localhost
几乎永远不会与Kubernetes一起使用,因为在拉取镜像时,它始终解析为Kubernetes节点的本地IP。这意味着您将必须具有注册表和kubelet在完全相同的VM上提取镜像。
我只专注于使其与运行注册表的VM IP地址一起使用,并确保Kubernetes VM可以访问注册表VM IP地址。另外,请记住,在运行注册表时,在这种情况下,还必须公开容器端口5000
附言您没有指定要运行的虚拟机监控程序? VirtualBox? VMware?您在使用桥接网络吗?仅限主机❓
✌️
关于docker - Kubectl创建部署无法从本地docker repo连接中提取图像被拒绝,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63333916/