[英]Google Cloud Container Registry/Artifact Registry Permissions
我正在嘗試使用 Google Cloud SDK 將容器推送到 Windows 10 上的 Google Cloud Container Registry 或 Google Cloud Artifact Registry。這兩種服務都出現了類似的權限錯誤,但我似乎無法弄清楚原因。 對於 Container Registry,推送時我得到:
> docker push us.gcr.io/{PROJECT}/{PATH}/{CONTAINER}:{TAG}
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
對於 Artifact Registry,推送時我得到:
> docker push northamerica-northeast1-docker.pkg.dev/{PROJECT}/{REPOSITORY}/{CONTAINER}:{TAG}
denied: Permission "artifactregistry.repositories.downloadArtifacts" denied on resource
"projects/opallabs/locations/northamerica-northeast1/repositories/domar" (or it may not exist)
我已經運行gcloud init
和gcloud auth configure-docker
幾次。 我可以使用gcloud
從命令行輕松創建和編輯 Google Cloud 資源。 我是 Google Cloud 項目的所有者,但為了安全起見,我給自己分配了存儲管理員、工件注冊表管理員、工件注冊表存儲庫管理員。 但是,當我運行gcloud auth print-access-token
並使用https://www.googleapis.com/oauth2/v1/tokeninfo
端點分析令牌時,唯一出現的范圍是:
{
...
"scope": "openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloud-
platform https://www.googleapis.com/auth/appengine.admin https://www.googleapis.com/auth/compute
https://www.googleapis.com/auth/accounts.reauth",
...
}
缺少https://www.googleapis.com/auth/devstorage.read_write
或https://www.googleapis.com/auth/devstorage.full_control
范圍,根據故障排除鏈接,它們可能應該在那里,但我'我不確定為什么他們會失蹤。 按照設置說明,我在最后一台 Windows 10 機器上進行了此操作,但我的新機器上的相同設置似乎不起作用。
我的 docker 憑證助手條目:
{
"credHelpers": {
"gcr.io": "gcloud",
"us.gcr.io": "gcloud",
"eu.gcr.io": "gcloud",
"asia.gcr.io": "gcloud",
"staging-k8s.gcr.io": "gcloud",
"marketplace.gcr.io": "gcloud",
"northamerica-northeast1-docker.pkg.dev": "gcloud",
"us-central1-docker.pkg.dev": "gcloud"
}
}
> docker-credential-gcloud list
{
"https://asia.gcr.io": "_dcgcloud_token",
"https://eu.gcr.io": "_dcgcloud_token",
"https://gcr.io": "_dcgcloud_token",
"https://marketplace.gcr.io": "_dcgcloud_token",
"https://staging-k8s.gcr.io": "_dcgcloud_token",
"https://us.gcr.io": "_dcgcloud_token"
}
gcloud -v
谷歌雲 SDK 311.0.0
測試版 2020.09.18
bq 2.0.60
核心 2020.09.18
gsutil 4.53
docker -v
Docker 版本 19.03.13,內部版本 4484c46d9d
感謝Muss Rahman提供的鏈接,我已經能夠通過在 Docker 桌面中轉到“設置”->“命令行”並取消選中“啟用雲體驗”開關來進行身份驗證。 docker 手冊中似乎沒有該設置,所以我不確定它如何影響身份驗證,我所知道的是,對於 Docker 版本 19.03.13,在 Windows 上構建 4484c46d9d,如果您想使用 gcloud 進行身份驗證,則需要禁用。
嘗試配置:
gcloud auth configure-docker northamerica-northeast1-docker.pkg.dev
當我拼錯我的項目名稱時,我遇到了這個問題。 仔細檢查您的路徑是否符合https://cloud.google.com/artifact-registry/docs/docker/pushing-and-pulling#auth上的說明
您將必須提供特定於項目或特定於 repo 的權限。 經過大量的研究,我知道了。
https://cloud.google.com/artifact-registry/docs/access-control#grant-repo
您可以提供您的 IAM email 並提供工件注冊表編寫器。
注意:即使您將 IAM 的所有者權限授予整個項目,它也不會起作用,因為 Artifact 注冊表本身有自己的權限系統。 這需要一段時間才能識別
以防其他人遇到這個。 對我來說問題是你必須使用PROJECT-ID
這與項目名稱不同
例如,如果您的項目名為example
,您可能有:
docker tag image:tag northamerica-northeast1-docker.pkg.dev/example/repo-name/image:tag
docker push northamerica-northeast1-docker.pkg.dev/example/repo-name/image:tag
這看起來很愚蠢,但很可能是你的問題。 如果是的話
PROJECT-ID
: gcloud projects list
(注意:它是第一列值,而不是最后一列中的“項目編號”)docker tag image:tag northamerica-northeast1-docker.pkg.dev/<PROJECT-ID>/repo-name/image:tag
docker push northamerica-northeast1-docker.pkg.dev/<PROJECT-ID>/repo-name/image:tag
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.