[英]Docker fails to push images to Google Cloud Registry
I am trying to push a Docker image to Google Cloud Registry via the GitLab ci pipeline.我正在尝试通过 GitLab ci 管道将 Docker 图像推送到 Google Cloud Registry。
The image builds but when its time to push to registry i get the following error.图像构建,但是当它推送到注册表时,我收到以下错误。
denied: Token exchange failed for project 'xxx-dev01-xxxxx'.
拒绝:项目“xxx-dev01-xxxxxx”的令牌交换失败。 Org Policy Violated: 'eu' violates constraint 'constraints/gcp.resourceLocations'
违反组织政策:“eu”违反了约束“constraints/gcp.resourceLocations”
.gitlab.yaml .gitlab.yaml
deploy:dev:
allow_failure: true
extends:
- .prod
stage: Deploy
image: google/cloud-sdk
services:
- docker:dind
variables:
IMAGE_TAG: "eu.gcr.io/$PROJECT_ID/testapp"
before_script:
- echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
- gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json
- gcloud config set project $DEV_PROJECT_ID
- gcloud auth configure-docker
- gcloud services enable containerregistry.googleapis.com
- docker login -u _json_key --password-stdin https://eu.gcr.io < ${HOME}/gcloud-service-key.json
script:
- docker build . -t "$IMAGE_TAG"
- docker push $IMAGE_TAG:latest
when: manual
It seems to violate one of your Organisation Policy, the "resource location" one.它似乎违反了您的一项组织政策,即“资源位置”之一。
According to the documentation, it looks like your company is preventing you to store data into this location (region).根据文档,您的公司似乎阻止您将数据存储到此位置(区域)。
https://cloud.google.com/resource-manager/docs/organization-policy/defining-locations https://cloud.google.com/resource-manager/docs/organization-policy/defining-locations
You might want to try to change the eu.gcr.io
with another one from this list.您可能想尝试使用此列表中的另一个更改
eu.gcr.io
。
https://cloud.google.com/container-registry/docs/pushing-and-pulling#add-registry https://cloud.google.com/container-registry/docs/pushing-and-pulling#add-registry
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.