Docker在Powershell中登录到gcr.io [英] Docker Login to gcr.io in Powershell

查看:100
本文介绍了Docker在Powershell中登录到gcr.io的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 JSON密钥文件.我可以在Mac上正常工作,因此密钥文件肯定可以正常工作.

I'm trying to log in to Google's Container Registry on Windows 10 by using a JSON Key file. I have this working without issues on my Mac so the keyfile is definitely working.

首先,我在获取docker登录功能以接受JSON密钥文件的内容方面遇到问题.我尝试在CMD中运行"/set/p PASS ... "命令,并在Powershell中尝试了类似的方法:

First off I had issues getting the docker login function to accept the contents of the JSON key file. I've tried running the "/set /p PASS..." command in CMD and I've tried something along the lines of this in Powershell:

docker login -u _json_key -p"$(获取内容密钥文件.json)" https://gcr.io

所有这些都会导致错误或此错误:

These all result in either an error or this:

"docker登录"最多需要1个参数.

"docker login" requires at most 1 argument.

由于我无法使它正常工作,我跑了:

Since I couldn't get this to work, I ran:

docker login -u _json_key https://gcr.io

然后手动从JSON文件中删除所有中断,将其复制到剪贴板并在提示输入密码时将其粘贴.

And then just removed all breaks from the JSON file manually, copied it to clipboard and pasted it when prompted for my password.

结果是:

成功登录

问题解决了!对吧?

显然不是.我仍然无法提取图像,并且当我运行 docker info 时,列出的唯一注册表是"

Well apparently not. I was still unable to pull my images and when I ran docker info the only registry listed was "https://index.docker.io/v1/".

我尝试以admin身份启动Powershell,然后重新启动并重置docker,但似乎无济于事.

I've tried starting Powershell as admin, and restarted and reset docker but nothing seems to help.

任何人都知道发生了什么事吗?我该如何调试呢?

Anyone got any clue what is going on? How do I debug this?

我正在运行Docker 17.12.0版(稳定版)

I'm running Docker version 17.12.0 (stable)

推荐答案

我找到了既适用于Windows(在PowerShell中)又适用于bash的解决方案.秘密是使用提供一个使用stdin的密码" .

I found a solution that works for both Windows (in PowerShell) and bash. The secret is to use the "provide a password using stdin".

cat gcr_registry-ro.json | docker login -u _json_key --password-stdin https://gcr.io
Login Succeeded

帮助文本和版本:

PS C:\Users\andy> docker login --help

Usage:  docker login [OPTIONS] [SERVER]

Log in to a Docker registry

Options:
  -p, --password string   Password
      --password-stdin    Take the password from stdin
  -u, --username string   Username
PS C:\Users\andy> docker -v
Docker version 18.06.1-ce, build e68fc7a
PS C:\Users\andy>

这篇关于Docker在Powershell中登录到gcr.io的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆