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.
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 "$(Get-Content keyfile.json)" https://gcr.io
These all result in either an error or this:
"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
And then just removed all breaks from the JSON file manually, copied it to clipboard and pasted it when prompted for my password.
That results in:
Login Succeeded
Problem solved! Right?
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/".
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?
I'm running Docker version 17.12.0 (stable)
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
Help text and versions:
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>