[英]Docker “Login succeeded” but still cannot push to GCP private registry
I am having issues while I am pushing my docker image to my private GCP registry. 当我将docker镜像推送到我的私有GCP注册表时,我遇到了问题。 I created a new Service account with Owner role from Google Cloud Platform. 我使用Google Cloud Platform的所有者角色创建了一个新的服务帐户。 Then I created a service key and copied the content of the json file (that I downloaded from the Service Account) in the $GCP_SERVICE_KEY variable in Gitlab CI/CD Variables. 然后我创建了一个服务密钥,并将Gson文件(我从服务帐户下载)的内容复制到Gitlab CI / CD变量中的$ GCP_SERVICE_KEY变量中。
This my .gitlab-ci.yaml file: 这是我的.gitlab-ci.yaml文件:
image: python:3.6
stages:
- push
before_script:
- mkdir -p $HOME/.docker
- echo "$GCP_SERVICE_KEY" >> "$HOME/.docker/config.json"
dockerpush:
stage: push
image: docker:stable
services:
- docker:dind
script:
- docker build --build-arg MONGODB_URI=$MONGODB_URI -t my_image_name .
- docker login -u _json_key --password-stdin https://gcr.io < $HOME/.docker/config.json
- docker tag my_image_name eu.gcr.io/my_project_id/my_image_name
- docker push eu.gcr.io/my_project_id/my_image_name
When I check the console logs, I see "Login succeeded". 当我检查控制台日志时,我看到“登录成功”。 But I cannot push to my GCP registry. 但我无法推送到我的GCP注册表。 I checked the Project ID, Roles of my user, everything seems okay. 我检查了项目ID,我的用户的角色,一切似乎都没问题。 But why do I still see the "unauthorized "error? 但为什么我仍然看到“未经授权”的错误?
$ docker login -u _json_key -p "$GCP_SERVICE_KEY" https://gcr.io
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ docker tag my_image_name eu.gcr.io/my_project_id/my_image_name
$ docker push eu.gcr.io/my_project_id/my_image_name
The push refers to repository
Preparing
Preparing
unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials.
To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
You're logging in to https://gcr.io
, but pushing to https://eu.gcr.io
您正在登录https://gcr.io
,但请访问https://eu.gcr.io
Update your docker login
command to https://eu.gcr.io
将docker login
命令更新为https://eu.gcr.io
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.