Kubernetes无法从私有Docker映像存储库中提取映像 [英] Kubernetes cannot pull image from private docker image repository

查看:82
本文介绍了Kubernetes无法从私有Docker映像存储库中提取映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用kubernetes(minikube)时遇到问题,并从docker上的本地映像存储库中提取了映像. Docker存储库已创建:

I have problem with kubernetes (minikube) and pull images from local image repository on docker. Docker repository was created:

docker run --entrypoint htpasswd registry:2 -Bbn zordon examplePassword > /mnt/LINUX/auth/htpasswd

docker run -d \
  -p 5000:5000 \
  --restart=always \
  --name registry \
  -v /mnt/LINUX/dockerreg:/var/lib/registry \
  -v /mnt/LINUX/auth:/auth \
  -e "REGISTRY_AUTH=htpasswd" \
  -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
  -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
  registry:2

然后我要创建一个具有成功上载到本地存储库的图像的简单pod:

Then I want to create simple pod with image which was succesfully uploaded to local repository:

curl localhost:5000/v2/_catalog
{"repositories":["car/configuration"]}

我还使用以下方法在minikube集群上创建了秘密:

I have also create secret on minikube cluster with:

kubectl create secret docker-registry docregkey --docker-server=localhost:5000 --docker-username=zordon --docker-password=examplePassword --docker-email=test@dock.mail

并定义简单的Pod:

    apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: car/configuration:latest
    imagePullPolicy: Always
  restartPolicy: Always
  imagePullSecrets:
  - name: docregkey

不幸的是,我静止不动:

unfortunatelly I getting still:

无法提取映像"car/configuration:latest":rpc错误:代码= 未知的desc =来自守护程序的错误响应:拉取访问被拒绝 汽车/配置,存储库不存在或可能需要'docker 登录"

Failed to pull image "car/configuration:latest": rpc error: code = Unknown desc = Error response from daemon: pull access denied for car/configuration, repository does not exist or may require 'docker login'

我如何解决此问题?

推荐答案

问题在于图像提取策略-您已将其设置为Always(默认设置).这意味着Docker守护进程始终尝试从外部Docker注册表中提取映像-您想使用本地的Docker注册表.

The problem is with the image pull policy - you have set this to Always (the default setting). This means that the Docker deamon always tries to pull the image from the outer Docker registry - you want to use the local one instead.

尝试在创建展开时添加--image-pull-policy=Never.

Try to add --image-pull-policy=Never when creating a deployment.

使用本地创建的图像的一个很好的教程在这里(它对我有帮助):

A good tutorial of using locally created images is here (it helped me):

https://kubernetes.io/docs/tutorials/hello-minikube/#create-a-docker-container-image

这篇关于Kubernetes无法从私有Docker映像存储库中提取映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆