问题描述
我正尝试从Docker集线器中提取一个私有映像,每次在pod上使用describe收到错误 ImagePullBackOff时,我看到错误未授权:错误的用户名或密码,便在集群中创建了秘密使用以下指南:使用带有正确凭据的cli方法(我检查了一下,然后可以使用其中一个登录到网站),这是我的yaml文件。
I'm trying to pull a private image from docker hub and every time I get the error "ImagePullBackOff" using describe on the pods I see the error "unauthorized: incorrect username or password", I created the secret in the cluster using the following guide: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ using the cli method with the correct credentials (I checked and I can login on the website with these one) and this is my yaml file.
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-typescript
labels:
app: app-typescript
spec:
selector:
matchLabels:
app: app-typescript
replicas: 1
minReadySeconds: 15
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: app-typescript
spec:
containers:
- name: api
image: dockerhuborg/api:latest
imagePullPolicy: Always
env:
- name: "ENV_TYPE"
value: "production"
- name: "NODE_ENV"
value: "production"
- name: "MONGODB_URI"
value: "mongodb://mongo-mongodb/db"
ports:
- containerPort: 4000
imagePullSecrets:
- name: regcred
推荐答案
我找到了一个解决方案,显然问题是docker hub使用不同的域进行登录和容器拉出,因此您必须编辑使用kubectl命令创建的秘密,并用.dockerconfigjson的base64替换为这个json的编码base64版本(是的,我知道也许我添加了t太多域,但我正尝试从大约2天之内解决此问题,我再也没有耐心来找到确切的域了)
I found a solution, apparently the problem is that docker hub use different domains for login and containers pulling, so you must edit your secret created with the kubectl command and replace the base64 of .dockerconfigjson with an encoded base64 version of this json (yeah I know maybe I added too much domain but I'm trying to fix this sh*t from about 2 days I don't have patience anymore to find the exact ones)
{
"auths":{
"https://index.docker.io/v1/":{
"username":"user",
"password":"password",
"email":"[email protected]",
"auth":"base64 of string user:password"
},
"auth.docker.io":{
"username":"user",
"password":"password",
"email":"[email protected]",
"auth":"base64 of string user:password"
},
"registry.docker.io":{
"username":"user",
"password":"password",
"email":"[email protected]",
"auth":"base64 of string user:password"
},
"docker.io":{
"username":"user",
"password":"password",
"email":"[email protected]",
"auth":"base64 of string user:password"
},
"https://registry-1.docker.io/v2/": {
"username":"user",
"password":"password",
"email":"[email protected]",
"auth":"base64 of string user:password"
},
"registry-1.docker.io/v2/": {
"username":"user",
"password":"password",
"email":"[email protected]",
"auth":"base64 of string user:password"
},
"registry-1.docker.io": {
"username":"user",
"password":"password",
"email":"[email protected]",
"auth":"base64 of string user:password"
},
"https://registry-1.docker.io": {
"username":"user",
"password":"password",
"email":"[email protected]",
"auth":"base64 of string user:password"
}
}
}
这篇关于kubernetes中的dockerhub提供未经授权的用户名或密码正确的凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!