Sri*_*wal 19 docker docker-image
我正在尝试将我的 docker 映像推送到 google 容器映像注册表,但收到一条错误消息,指出我没有执行此操作所需的权限。
我已经尝试过 gcloud auth configure-docker 但它对我不起作用。
我首先使用以下命令构建映像: docker build -t gcr.io/trynew/hello-world-image:v1 。
然后我试图附加一个标签并推送它: docker push gcr.io/trynew/hello-world-image:v1
这是我的输出:
The push refers to repository [gcr.io/trynew/hello-world-image]
e62774cdb1c2: Preparing
0f6265b750f3: Preparing
f82351274ce3: Preparing
31a16430afc8: Preparing
67298499a3ed: Preparing
62d5f39c8fe4: Waiting
9f8566ee5135: Waiting
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
Run Code Online (Sandbox Code Playgroud)
ha7*_*ilm 31
如果您以 root 身份运行docker(即使用sudo docker),则请确保将身份验证配置为 root。您可以运行例如:
sudo -s
gcloud auth login
gcloud auth configure-docker
Run Code Online (Sandbox Code Playgroud)
...这将在/root/.docker/config.json.
gcloud auth login( as 有任何安全隐患吗root?请在评论中告诉我。)
小智 29
谷歌云服务有关于如何授予 docker push 权限的具体信息,我认为这是你应该看的第一件事,https://cloud.google.com/container-registry/docs/access-control
在检查您是否有足够的权限后,您应该继续使用以下内容进行身份验证:
gcloud auth configure-docker
Run Code Online (Sandbox Code Playgroud)
在此处查看更多信息:https : //cloud.google.com/container-registry/docs/pushing-and-pulling
Arm*_*vas 14
为了能够将映像推送到私有注册表,您需要做两件事:API 访问范围和使用注册表对您的 VM 进行身份验证。
对于API 访问范围(https://cloud.google.com/container-registry/docs/using-with-google-cloud-platform),我们可以在官方文档中阅读:
对于 GKE:
默认情况下,创建的新 Google Kubernetes Engine 集群具有存储桶的只读权限。要在创建 Google Kubernetes Engine 集群时设置读写存储范围,请使用 --scopes 选项。
对于 GCE:
默认情况下,Compute Engine 虚拟机具有为存储分区配置的只读访问范围。要推送私有 Docker 映像,您的实例必须具有按访问范围中所述配置的读写存储访问范围。
因此,首先,验证您的 GKE 集群或 GCE 实例是否确实设置了正确的范围。
接下来是对注册表进行身份验证:
a) 如果您使用的是基于 Linux 的映像,则需要使用“ gcloud auth configure-docker ”(https://cloud.google.com/container-registry/docs/advanced-authentication)。
b) 对于容器优化操作系统 (COS),命令是“ docker-credential-gcr configure-docker ”(https://cloud.google.com/container-optimized-os/docs/how-to/run-container -instance#accessing_private_google_container_registry )
docker push当我在安装 SDK 时打开的 google cloud shell 中进行身份验证后,尝试从普通的 powershell 窗口运行时,我在 Windows 上遇到了此错误。
解决方案很简单:
gcloud auth configure-docker运行命令后启动一个新的 powershell 窗口来运行 docker push。
确保您也激活了注册表:
gcloud services enable containerregistry.googleapis.com
Run Code Online (Sandbox Code Playgroud)
此外,Google 还倾向于跳转到默认帐户(可能是您的个人 Gmail),该帐户可能是也可能不是您想要的帐户(您的企业电子邮件)。如果您在浏览器中打开任何链接,请确保您使用的是正确的 Google 帐户。
我还不太确定发生了什么,因为我对 docker 是全新的,但是在启动新的 Powershell 实例时,有些东西得到了刷新。
这是唯一对我有用的方法。我在 kubernetes/kompose Github 问题中找到了它。
- 取出
credsStore钥匙~/.docker/config.json这将强制 docker 在您使用时将 auth 写入 json 中
docker login。您无法Securely store Docker logins in macOS keychain再在 docker 桌面中取消勾选 - 并且当前的credStore不再是 macOS 钥匙串,而是desktop.
gcloud auth login使用 gcloud 进行身份验证(明确地说)gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://eu.gcr.io你应该看到这个:
Run Code Online (Sandbox Code Playgroud)WARNING! Your password will be stored unencrypted in /Users/andrew/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded
来源:https ://github.com/kubernetes/kompose/issues/1043#issuecomment-609019141
首先,请确保您涵盖了以下官方文档中列出的所有要点
https://cloud.google.com/container-registry/docs/advanced-authentication
此错误主要是由于 docker 配置更新而发生,您可以使用命令检查cat .docker/config.json
现在使用以下命令更新 gcr
gcloud auth configure-docker
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13901 次 |
| 最近记录: |