I'm not sure if I have already logged in to a docker registry in cmd line by using cmd: docker login. How can you test or see whether you are logged in or not, without trying to push?
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
The docker cli credential scheme is unsurprisingly uncomplicated, just take a look:
cat ~\.docker\config.json
On Windows you can also poke around the credential tool which also lists the username, just to poke around too much ;)
. "C:\Program Files\Docker\Docker\resources\bin\docker-credential-wincred.exe" list
I use one of the following two ways for this check:
1: View config.json file:
In case you are logged in to "private.registry.com" you will see an entry for the same as following in
~/.docker/config.json
:2: Try docker login once again:
If you are trying to see if you already have an active session with private.registry.com, try to login again:
If you get an output like the above, it means
logged-in-user
already had an active session withprivate.registry.com
. If you are just promoted for username instead, that would indicate that there's no active session.Edit
You can login to docker with
docker login <repository>
If you are already logged in, the prompt will look like:
Answer below is obsolete,
docker info
no longer shows username information.Historic
When you are logged in, your username and registry shows up in thedocker info
commandLike this:
Edit: Note; this only works for
index.docker.io
repo. Login only stores the credentials on disk when it needs them, for example when runningdocker pull localhost:5000/image
ordocker pull quay.io/username/reponame
.Edited after this got pointed out in the comments of this question: how can I tell if I'm logged into a private docker registry
The answers here so far are not so useful:
docker info
no longer provides this infodocker logout
is a major inconvenience - unless you already know the credentials and can easily re-logindocker login
response seems quite unreliable and not so easy to parse by the programMy solution that worked for me builds on @noobuntu's comment: I figured that if I already known the image that I want to pull, but I'm not sure if the user is already logged in, I can do this:
Just checked, today it looks like this:
NOTE: this is on a macOS with the latest version of Docker CE, docker-credential-helper - both installed with homebrew.
Use command like below: