kubernetes 中的 dockerhub 未经授权:用户名或密码不正确,凭据正确
dockerhub in kubernetes give unauthorized: incorrect username or password with right credentials
我正在尝试从 docker 集线器中拉取私人图像,每次我在 pods 上使用描述时收到错误 "ImagePullBackOff" 我都会看到错误 "unauthorized: incorrect username or password", 我使用以下指南在集群中创建了秘密:https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ 使用 cli 方法和正确的凭据(我检查过,我可以用这些凭据登录网站),这是我的 yaml 文件。
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 命令创建的密钥并替换 .[=13 的 base64 =]configjson 带有此 json 的编码 base64 版本(是的,我知道也许我添加了太多的域,但我试图从大约 2 天开始修复这个 sh*t 我没有耐心等待找到确切的)
{
"auths":{
"https://index.docker.io/v1/":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"auth.docker.io":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"registry.docker.io":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"docker.io":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"https://registry-1.docker.io/v2/": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"registry-1.docker.io/v2/": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"registry-1.docker.io": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"https://registry-1.docker.io": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
}
}
}
我正在尝试从 docker 集线器中拉取私人图像,每次我在 pods 上使用描述时收到错误 "ImagePullBackOff" 我都会看到错误 "unauthorized: incorrect username or password", 我使用以下指南在集群中创建了秘密:https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ 使用 cli 方法和正确的凭据(我检查过,我可以用这些凭据登录网站),这是我的 yaml 文件。
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 命令创建的密钥并替换 .[=13 的 base64 =]configjson 带有此 json 的编码 base64 版本(是的,我知道也许我添加了太多的域,但我试图从大约 2 天开始修复这个 sh*t 我没有耐心等待找到确切的)
{
"auths":{
"https://index.docker.io/v1/":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"auth.docker.io":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"registry.docker.io":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"docker.io":{
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"https://registry-1.docker.io/v2/": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"registry-1.docker.io/v2/": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"registry-1.docker.io": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
},
"https://registry-1.docker.io": {
"username":"user",
"password":"password",
"email":"yourdockeremail@gmail.com",
"auth":"base64 of string user:password"
}
}
}