How to know if docker is already logged in to a docker registry server
up vote
50
down vote
favorite
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
add a comment |
up vote
50
down vote
favorite
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
Not sure I understand your question? do you want to know if you are logged in on a terminal? why not run %docker images command in the terminal and see if your images show up?
– noobuntu
Mar 15 '16 at 21:54
1
I want to know whether I am logged in to dockerhub registry in terminal. I thought the images are local, so it will just show the local images, not the dockerhub images.
– Ville Miekk-oja
Mar 15 '16 at 21:56
1
I believe once you are logged into docker, you are connected to your dockerhub registry. I don't think there is a separate login
– noobuntu
Mar 15 '16 at 22:01
add a comment |
up vote
50
down vote
favorite
up vote
50
down vote
favorite
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
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
docker
asked Mar 15 '16 at 21:50
Ville Miekk-oja
2,78992958
2,78992958
Not sure I understand your question? do you want to know if you are logged in on a terminal? why not run %docker images command in the terminal and see if your images show up?
– noobuntu
Mar 15 '16 at 21:54
1
I want to know whether I am logged in to dockerhub registry in terminal. I thought the images are local, so it will just show the local images, not the dockerhub images.
– Ville Miekk-oja
Mar 15 '16 at 21:56
1
I believe once you are logged into docker, you are connected to your dockerhub registry. I don't think there is a separate login
– noobuntu
Mar 15 '16 at 22:01
add a comment |
Not sure I understand your question? do you want to know if you are logged in on a terminal? why not run %docker images command in the terminal and see if your images show up?
– noobuntu
Mar 15 '16 at 21:54
1
I want to know whether I am logged in to dockerhub registry in terminal. I thought the images are local, so it will just show the local images, not the dockerhub images.
– Ville Miekk-oja
Mar 15 '16 at 21:56
1
I believe once you are logged into docker, you are connected to your dockerhub registry. I don't think there is a separate login
– noobuntu
Mar 15 '16 at 22:01
Not sure I understand your question? do you want to know if you are logged in on a terminal? why not run %docker images command in the terminal and see if your images show up?
– noobuntu
Mar 15 '16 at 21:54
Not sure I understand your question? do you want to know if you are logged in on a terminal? why not run %docker images command in the terminal and see if your images show up?
– noobuntu
Mar 15 '16 at 21:54
1
1
I want to know whether I am logged in to dockerhub registry in terminal. I thought the images are local, so it will just show the local images, not the dockerhub images.
– Ville Miekk-oja
Mar 15 '16 at 21:56
I want to know whether I am logged in to dockerhub registry in terminal. I thought the images are local, so it will just show the local images, not the dockerhub images.
– Ville Miekk-oja
Mar 15 '16 at 21:56
1
1
I believe once you are logged into docker, you are connected to your dockerhub registry. I don't think there is a separate login
– noobuntu
Mar 15 '16 at 22:01
I believe once you are logged into docker, you are connected to your dockerhub registry. I don't think there is a separate login
– noobuntu
Mar 15 '16 at 22:01
add a comment |
8 Answers
8
active
oldest
votes
up vote
30
down vote
accepted
Edit
You can login to docker with docker login <repository>
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username:
If you are already logged in, the prompt will look like:
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username (myusername):
Answer below is obsolete, docker info
no longer shows username information.
Historic
When you are logged in, your username and registry shows up in the docker info
command
Like this:
[ciccio@consolecowboy.net ~]$ docker info
Containers: 12
Running: 2
..etc...
...
Username: francobolli
Registry: https://index.docker.io/v1/
Edit: Note; this only works for index.docker.io
repo. Login only stores the credentials on disk when it needs them, for example when running docker pull localhost:5000/image
or docker 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
1
The last link talks about checking the contents of~/.docker/config.json
.
– dusan
Nov 27 '17 at 15:39
2
docker info
is apparently unreliable even for index.docker.io. Currently logged in alright and only see theRegistry
entry, noUsername
.
– famousgarkin
Apr 25 at 6:15
docker info is not showing Username anymore. I am on Windows, with docker version 18.05.0-ce.
– Giovanni Bassi
Jun 22 at 1:24
@GiovanniBassi I have updated my answer, thank you.
– Francesco de Guytenaere
Jun 24 at 17:05
1
What if a script needs to check?
– Teekin
Jul 7 at 11:03
add a comment |
up vote
24
down vote
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
:
"auths": {
"private.registry.com": {
"auth": "gibberishgibberishgibberishgibberishgibberishgibberish"
}
}
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:
bash$ docker login private.registry.com
Username (logged-in-user):
If you get an output like the above, it means logged-in-user
already had an active session with private.registry.com
. If you are just promoted for username instead, that would indicate that there's no active session.
Thanks a lot, this is the best answer
– Shqear
Mar 21 at 22:09
Yes, this is the best answer, because it provides a way to determine this in a shell script or other program.
– Teekin
Jul 7 at 11:05
add a comment |
up vote
4
down vote
For private registries, nothing is shown in docker info
. However, the logout command will tell you if you were logged in:
$ docker logout private.example.com
Not logged in to private.example.com
(Though this will force you to log in again.)
add a comment |
up vote
2
down vote
At least in "Docker for Windows" you can see if you are logged in to docker hub over the UI. Just right click the docker icon in the windows notification area:
add a comment |
up vote
2
down vote
The answers here so far are not so useful:
docker info
no longer provides this info
docker logout
is a major inconvenience - unless you already know the credentials and can easily re-login
docker login
response seems quite unreliable and not so easy to parse by the program
My 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:
try pulling target image
-> on failure:
try logging in
-> on failure: throw CannotLogInException
-> on success:
try pulling target image
-> on failure: throw CannotPullImageException
-> on success: (continue)
-> on success: (continue)
This is by far the best stratgy: just try a pull, if it fails then it is not logged in (the rest of the logic you have will depend on each use case, but the first try is universally applicable).
– Oliver
Nov 11 at 6:00
However someone pointed out on github.com/moby/moby/issues/15466 that there are many reasons for failure, not just login issue, yet docker exit status does not allow to differentiate reason for failure. It's still better than the other solutions, but a full solution would require a patch to docker.
– Oliver
Nov 11 at 6:08
add a comment |
up vote
1
down vote
Use command like below:
docker info | grep 'name'
WARNING: No swap limit support
Username: <strong>jonasm2009</strong>
add a comment |
up vote
0
down vote
Just checked, today it looks like this:
$ docker login
Authenticating with existing credentials...
Login Succeeded
NOTE: this is on a macOS with the latest version of Docker CE, docker-credential-helper - both installed with homebrew.
add a comment |
up vote
0
down vote
As pointed out by @Christian, best to try operation first then login only if necessary. Problem is that "if necessary" is not that obvious to do robustly. One approach is to compare the stderr of the docker operation with some strings that are known (by trial and error). For example,
try "docker OPERATION"
if it failed:
capture the stderr of "docker OPERATION"
if it ends with "no basic auth credentials":
try docker login
else if it ends with "not found":
fatal error: image name/tag probably incorrect
else if it ends with <other stuff you care to trap>:
...
else:
fatal error: unknown cause
try docker OPERATION again
if this fails: you're SOL!
add a comment |
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
30
down vote
accepted
Edit
You can login to docker with docker login <repository>
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username:
If you are already logged in, the prompt will look like:
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username (myusername):
Answer below is obsolete, docker info
no longer shows username information.
Historic
When you are logged in, your username and registry shows up in the docker info
command
Like this:
[ciccio@consolecowboy.net ~]$ docker info
Containers: 12
Running: 2
..etc...
...
Username: francobolli
Registry: https://index.docker.io/v1/
Edit: Note; this only works for index.docker.io
repo. Login only stores the credentials on disk when it needs them, for example when running docker pull localhost:5000/image
or docker 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
1
The last link talks about checking the contents of~/.docker/config.json
.
– dusan
Nov 27 '17 at 15:39
2
docker info
is apparently unreliable even for index.docker.io. Currently logged in alright and only see theRegistry
entry, noUsername
.
– famousgarkin
Apr 25 at 6:15
docker info is not showing Username anymore. I am on Windows, with docker version 18.05.0-ce.
– Giovanni Bassi
Jun 22 at 1:24
@GiovanniBassi I have updated my answer, thank you.
– Francesco de Guytenaere
Jun 24 at 17:05
1
What if a script needs to check?
– Teekin
Jul 7 at 11:03
add a comment |
up vote
30
down vote
accepted
Edit
You can login to docker with docker login <repository>
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username:
If you are already logged in, the prompt will look like:
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username (myusername):
Answer below is obsolete, docker info
no longer shows username information.
Historic
When you are logged in, your username and registry shows up in the docker info
command
Like this:
[ciccio@consolecowboy.net ~]$ docker info
Containers: 12
Running: 2
..etc...
...
Username: francobolli
Registry: https://index.docker.io/v1/
Edit: Note; this only works for index.docker.io
repo. Login only stores the credentials on disk when it needs them, for example when running docker pull localhost:5000/image
or docker 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
1
The last link talks about checking the contents of~/.docker/config.json
.
– dusan
Nov 27 '17 at 15:39
2
docker info
is apparently unreliable even for index.docker.io. Currently logged in alright and only see theRegistry
entry, noUsername
.
– famousgarkin
Apr 25 at 6:15
docker info is not showing Username anymore. I am on Windows, with docker version 18.05.0-ce.
– Giovanni Bassi
Jun 22 at 1:24
@GiovanniBassi I have updated my answer, thank you.
– Francesco de Guytenaere
Jun 24 at 17:05
1
What if a script needs to check?
– Teekin
Jul 7 at 11:03
add a comment |
up vote
30
down vote
accepted
up vote
30
down vote
accepted
Edit
You can login to docker with docker login <repository>
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username:
If you are already logged in, the prompt will look like:
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username (myusername):
Answer below is obsolete, docker info
no longer shows username information.
Historic
When you are logged in, your username and registry shows up in the docker info
command
Like this:
[ciccio@consolecowboy.net ~]$ docker info
Containers: 12
Running: 2
..etc...
...
Username: francobolli
Registry: https://index.docker.io/v1/
Edit: Note; this only works for index.docker.io
repo. Login only stores the credentials on disk when it needs them, for example when running docker pull localhost:5000/image
or docker 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
Edit
You can login to docker with docker login <repository>
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username:
If you are already logged in, the prompt will look like:
$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If
you don't have a Docker ID, head over to https://hub.docker.com to
create one.
Username (myusername):
Answer below is obsolete, docker info
no longer shows username information.
Historic
When you are logged in, your username and registry shows up in the docker info
command
Like this:
[ciccio@consolecowboy.net ~]$ docker info
Containers: 12
Running: 2
..etc...
...
Username: francobolli
Registry: https://index.docker.io/v1/
Edit: Note; this only works for index.docker.io
repo. Login only stores the credentials on disk when it needs them, for example when running docker pull localhost:5000/image
or docker 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
edited Jun 24 at 17:04
answered Mar 15 '16 at 23:07
Francesco de Guytenaere
2,26711631
2,26711631
1
The last link talks about checking the contents of~/.docker/config.json
.
– dusan
Nov 27 '17 at 15:39
2
docker info
is apparently unreliable even for index.docker.io. Currently logged in alright and only see theRegistry
entry, noUsername
.
– famousgarkin
Apr 25 at 6:15
docker info is not showing Username anymore. I am on Windows, with docker version 18.05.0-ce.
– Giovanni Bassi
Jun 22 at 1:24
@GiovanniBassi I have updated my answer, thank you.
– Francesco de Guytenaere
Jun 24 at 17:05
1
What if a script needs to check?
– Teekin
Jul 7 at 11:03
add a comment |
1
The last link talks about checking the contents of~/.docker/config.json
.
– dusan
Nov 27 '17 at 15:39
2
docker info
is apparently unreliable even for index.docker.io. Currently logged in alright and only see theRegistry
entry, noUsername
.
– famousgarkin
Apr 25 at 6:15
docker info is not showing Username anymore. I am on Windows, with docker version 18.05.0-ce.
– Giovanni Bassi
Jun 22 at 1:24
@GiovanniBassi I have updated my answer, thank you.
– Francesco de Guytenaere
Jun 24 at 17:05
1
What if a script needs to check?
– Teekin
Jul 7 at 11:03
1
1
The last link talks about checking the contents of
~/.docker/config.json
.– dusan
Nov 27 '17 at 15:39
The last link talks about checking the contents of
~/.docker/config.json
.– dusan
Nov 27 '17 at 15:39
2
2
docker info
is apparently unreliable even for index.docker.io. Currently logged in alright and only see the Registry
entry, no Username
.– famousgarkin
Apr 25 at 6:15
docker info
is apparently unreliable even for index.docker.io. Currently logged in alright and only see the Registry
entry, no Username
.– famousgarkin
Apr 25 at 6:15
docker info is not showing Username anymore. I am on Windows, with docker version 18.05.0-ce.
– Giovanni Bassi
Jun 22 at 1:24
docker info is not showing Username anymore. I am on Windows, with docker version 18.05.0-ce.
– Giovanni Bassi
Jun 22 at 1:24
@GiovanniBassi I have updated my answer, thank you.
– Francesco de Guytenaere
Jun 24 at 17:05
@GiovanniBassi I have updated my answer, thank you.
– Francesco de Guytenaere
Jun 24 at 17:05
1
1
What if a script needs to check?
– Teekin
Jul 7 at 11:03
What if a script needs to check?
– Teekin
Jul 7 at 11:03
add a comment |
up vote
24
down vote
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
:
"auths": {
"private.registry.com": {
"auth": "gibberishgibberishgibberishgibberishgibberishgibberish"
}
}
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:
bash$ docker login private.registry.com
Username (logged-in-user):
If you get an output like the above, it means logged-in-user
already had an active session with private.registry.com
. If you are just promoted for username instead, that would indicate that there's no active session.
Thanks a lot, this is the best answer
– Shqear
Mar 21 at 22:09
Yes, this is the best answer, because it provides a way to determine this in a shell script or other program.
– Teekin
Jul 7 at 11:05
add a comment |
up vote
24
down vote
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
:
"auths": {
"private.registry.com": {
"auth": "gibberishgibberishgibberishgibberishgibberishgibberish"
}
}
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:
bash$ docker login private.registry.com
Username (logged-in-user):
If you get an output like the above, it means logged-in-user
already had an active session with private.registry.com
. If you are just promoted for username instead, that would indicate that there's no active session.
Thanks a lot, this is the best answer
– Shqear
Mar 21 at 22:09
Yes, this is the best answer, because it provides a way to determine this in a shell script or other program.
– Teekin
Jul 7 at 11:05
add a comment |
up vote
24
down vote
up vote
24
down vote
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
:
"auths": {
"private.registry.com": {
"auth": "gibberishgibberishgibberishgibberishgibberishgibberish"
}
}
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:
bash$ docker login private.registry.com
Username (logged-in-user):
If you get an output like the above, it means logged-in-user
already had an active session with private.registry.com
. If you are just promoted for username instead, that would indicate that there's no active session.
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
:
"auths": {
"private.registry.com": {
"auth": "gibberishgibberishgibberishgibberishgibberishgibberish"
}
}
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:
bash$ docker login private.registry.com
Username (logged-in-user):
If you get an output like the above, it means logged-in-user
already had an active session with private.registry.com
. If you are just promoted for username instead, that would indicate that there's no active session.
edited Mar 22 at 0:50
Leon Bambrick
17.5k84371
17.5k84371
answered Nov 30 '17 at 19:03
Arnab
425411
425411
Thanks a lot, this is the best answer
– Shqear
Mar 21 at 22:09
Yes, this is the best answer, because it provides a way to determine this in a shell script or other program.
– Teekin
Jul 7 at 11:05
add a comment |
Thanks a lot, this is the best answer
– Shqear
Mar 21 at 22:09
Yes, this is the best answer, because it provides a way to determine this in a shell script or other program.
– Teekin
Jul 7 at 11:05
Thanks a lot, this is the best answer
– Shqear
Mar 21 at 22:09
Thanks a lot, this is the best answer
– Shqear
Mar 21 at 22:09
Yes, this is the best answer, because it provides a way to determine this in a shell script or other program.
– Teekin
Jul 7 at 11:05
Yes, this is the best answer, because it provides a way to determine this in a shell script or other program.
– Teekin
Jul 7 at 11:05
add a comment |
up vote
4
down vote
For private registries, nothing is shown in docker info
. However, the logout command will tell you if you were logged in:
$ docker logout private.example.com
Not logged in to private.example.com
(Though this will force you to log in again.)
add a comment |
up vote
4
down vote
For private registries, nothing is shown in docker info
. However, the logout command will tell you if you were logged in:
$ docker logout private.example.com
Not logged in to private.example.com
(Though this will force you to log in again.)
add a comment |
up vote
4
down vote
up vote
4
down vote
For private registries, nothing is shown in docker info
. However, the logout command will tell you if you were logged in:
$ docker logout private.example.com
Not logged in to private.example.com
(Though this will force you to log in again.)
For private registries, nothing is shown in docker info
. However, the logout command will tell you if you were logged in:
$ docker logout private.example.com
Not logged in to private.example.com
(Though this will force you to log in again.)
answered Jul 7 '17 at 17:18
Wilfred Hughes
16.4k1090128
16.4k1090128
add a comment |
add a comment |
up vote
2
down vote
At least in "Docker for Windows" you can see if you are logged in to docker hub over the UI. Just right click the docker icon in the windows notification area:
add a comment |
up vote
2
down vote
At least in "Docker for Windows" you can see if you are logged in to docker hub over the UI. Just right click the docker icon in the windows notification area:
add a comment |
up vote
2
down vote
up vote
2
down vote
At least in "Docker for Windows" you can see if you are logged in to docker hub over the UI. Just right click the docker icon in the windows notification area:
At least in "Docker for Windows" you can see if you are logged in to docker hub over the UI. Just right click the docker icon in the windows notification area:
answered Sep 3 '17 at 8:32
BaluJr.
292311
292311
add a comment |
add a comment |
up vote
2
down vote
The answers here so far are not so useful:
docker info
no longer provides this info
docker logout
is a major inconvenience - unless you already know the credentials and can easily re-login
docker login
response seems quite unreliable and not so easy to parse by the program
My 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:
try pulling target image
-> on failure:
try logging in
-> on failure: throw CannotLogInException
-> on success:
try pulling target image
-> on failure: throw CannotPullImageException
-> on success: (continue)
-> on success: (continue)
This is by far the best stratgy: just try a pull, if it fails then it is not logged in (the rest of the logic you have will depend on each use case, but the first try is universally applicable).
– Oliver
Nov 11 at 6:00
However someone pointed out on github.com/moby/moby/issues/15466 that there are many reasons for failure, not just login issue, yet docker exit status does not allow to differentiate reason for failure. It's still better than the other solutions, but a full solution would require a patch to docker.
– Oliver
Nov 11 at 6:08
add a comment |
up vote
2
down vote
The answers here so far are not so useful:
docker info
no longer provides this info
docker logout
is a major inconvenience - unless you already know the credentials and can easily re-login
docker login
response seems quite unreliable and not so easy to parse by the program
My 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:
try pulling target image
-> on failure:
try logging in
-> on failure: throw CannotLogInException
-> on success:
try pulling target image
-> on failure: throw CannotPullImageException
-> on success: (continue)
-> on success: (continue)
This is by far the best stratgy: just try a pull, if it fails then it is not logged in (the rest of the logic you have will depend on each use case, but the first try is universally applicable).
– Oliver
Nov 11 at 6:00
However someone pointed out on github.com/moby/moby/issues/15466 that there are many reasons for failure, not just login issue, yet docker exit status does not allow to differentiate reason for failure. It's still better than the other solutions, but a full solution would require a patch to docker.
– Oliver
Nov 11 at 6:08
add a comment |
up vote
2
down vote
up vote
2
down vote
The answers here so far are not so useful:
docker info
no longer provides this info
docker logout
is a major inconvenience - unless you already know the credentials and can easily re-login
docker login
response seems quite unreliable and not so easy to parse by the program
My 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:
try pulling target image
-> on failure:
try logging in
-> on failure: throw CannotLogInException
-> on success:
try pulling target image
-> on failure: throw CannotPullImageException
-> on success: (continue)
-> on success: (continue)
The answers here so far are not so useful:
docker info
no longer provides this info
docker logout
is a major inconvenience - unless you already know the credentials and can easily re-login
docker login
response seems quite unreliable and not so easy to parse by the program
My 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:
try pulling target image
-> on failure:
try logging in
-> on failure: throw CannotLogInException
-> on success:
try pulling target image
-> on failure: throw CannotPullImageException
-> on success: (continue)
-> on success: (continue)
answered Oct 11 at 23:47
Christian
20.6k1190140
20.6k1190140
This is by far the best stratgy: just try a pull, if it fails then it is not logged in (the rest of the logic you have will depend on each use case, but the first try is universally applicable).
– Oliver
Nov 11 at 6:00
However someone pointed out on github.com/moby/moby/issues/15466 that there are many reasons for failure, not just login issue, yet docker exit status does not allow to differentiate reason for failure. It's still better than the other solutions, but a full solution would require a patch to docker.
– Oliver
Nov 11 at 6:08
add a comment |
This is by far the best stratgy: just try a pull, if it fails then it is not logged in (the rest of the logic you have will depend on each use case, but the first try is universally applicable).
– Oliver
Nov 11 at 6:00
However someone pointed out on github.com/moby/moby/issues/15466 that there are many reasons for failure, not just login issue, yet docker exit status does not allow to differentiate reason for failure. It's still better than the other solutions, but a full solution would require a patch to docker.
– Oliver
Nov 11 at 6:08
This is by far the best stratgy: just try a pull, if it fails then it is not logged in (the rest of the logic you have will depend on each use case, but the first try is universally applicable).
– Oliver
Nov 11 at 6:00
This is by far the best stratgy: just try a pull, if it fails then it is not logged in (the rest of the logic you have will depend on each use case, but the first try is universally applicable).
– Oliver
Nov 11 at 6:00
However someone pointed out on github.com/moby/moby/issues/15466 that there are many reasons for failure, not just login issue, yet docker exit status does not allow to differentiate reason for failure. It's still better than the other solutions, but a full solution would require a patch to docker.
– Oliver
Nov 11 at 6:08
However someone pointed out on github.com/moby/moby/issues/15466 that there are many reasons for failure, not just login issue, yet docker exit status does not allow to differentiate reason for failure. It's still better than the other solutions, but a full solution would require a patch to docker.
– Oliver
Nov 11 at 6:08
add a comment |
up vote
1
down vote
Use command like below:
docker info | grep 'name'
WARNING: No swap limit support
Username: <strong>jonasm2009</strong>
add a comment |
up vote
1
down vote
Use command like below:
docker info | grep 'name'
WARNING: No swap limit support
Username: <strong>jonasm2009</strong>
add a comment |
up vote
1
down vote
up vote
1
down vote
Use command like below:
docker info | grep 'name'
WARNING: No swap limit support
Username: <strong>jonasm2009</strong>
Use command like below:
docker info | grep 'name'
WARNING: No swap limit support
Username: <strong>jonasm2009</strong>
edited Jul 20 at 17:05
xploshioOn
2,97311729
2,97311729
answered Jul 20 at 2:23
Meng Jonas
112
112
add a comment |
add a comment |
up vote
0
down vote
Just checked, today it looks like this:
$ docker login
Authenticating with existing credentials...
Login Succeeded
NOTE: this is on a macOS with the latest version of Docker CE, docker-credential-helper - both installed with homebrew.
add a comment |
up vote
0
down vote
Just checked, today it looks like this:
$ docker login
Authenticating with existing credentials...
Login Succeeded
NOTE: this is on a macOS with the latest version of Docker CE, docker-credential-helper - both installed with homebrew.
add a comment |
up vote
0
down vote
up vote
0
down vote
Just checked, today it looks like this:
$ docker login
Authenticating with existing credentials...
Login Succeeded
NOTE: this is on a macOS with the latest version of Docker CE, docker-credential-helper - both installed with homebrew.
Just checked, today it looks like this:
$ docker login
Authenticating with existing credentials...
Login Succeeded
NOTE: this is on a macOS with the latest version of Docker CE, docker-credential-helper - both installed with homebrew.
answered Aug 11 at 21:31
todd_dsm
3311517
3311517
add a comment |
add a comment |
up vote
0
down vote
As pointed out by @Christian, best to try operation first then login only if necessary. Problem is that "if necessary" is not that obvious to do robustly. One approach is to compare the stderr of the docker operation with some strings that are known (by trial and error). For example,
try "docker OPERATION"
if it failed:
capture the stderr of "docker OPERATION"
if it ends with "no basic auth credentials":
try docker login
else if it ends with "not found":
fatal error: image name/tag probably incorrect
else if it ends with <other stuff you care to trap>:
...
else:
fatal error: unknown cause
try docker OPERATION again
if this fails: you're SOL!
add a comment |
up vote
0
down vote
As pointed out by @Christian, best to try operation first then login only if necessary. Problem is that "if necessary" is not that obvious to do robustly. One approach is to compare the stderr of the docker operation with some strings that are known (by trial and error). For example,
try "docker OPERATION"
if it failed:
capture the stderr of "docker OPERATION"
if it ends with "no basic auth credentials":
try docker login
else if it ends with "not found":
fatal error: image name/tag probably incorrect
else if it ends with <other stuff you care to trap>:
...
else:
fatal error: unknown cause
try docker OPERATION again
if this fails: you're SOL!
add a comment |
up vote
0
down vote
up vote
0
down vote
As pointed out by @Christian, best to try operation first then login only if necessary. Problem is that "if necessary" is not that obvious to do robustly. One approach is to compare the stderr of the docker operation with some strings that are known (by trial and error). For example,
try "docker OPERATION"
if it failed:
capture the stderr of "docker OPERATION"
if it ends with "no basic auth credentials":
try docker login
else if it ends with "not found":
fatal error: image name/tag probably incorrect
else if it ends with <other stuff you care to trap>:
...
else:
fatal error: unknown cause
try docker OPERATION again
if this fails: you're SOL!
As pointed out by @Christian, best to try operation first then login only if necessary. Problem is that "if necessary" is not that obvious to do robustly. One approach is to compare the stderr of the docker operation with some strings that are known (by trial and error). For example,
try "docker OPERATION"
if it failed:
capture the stderr of "docker OPERATION"
if it ends with "no basic auth credentials":
try docker login
else if it ends with "not found":
fatal error: image name/tag probably incorrect
else if it ends with <other stuff you care to trap>:
...
else:
fatal error: unknown cause
try docker OPERATION again
if this fails: you're SOL!
answered Nov 11 at 7:04
Oliver
15.2k32444
15.2k32444
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36022892%2fhow-to-know-if-docker-is-already-logged-in-to-a-docker-registry-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Not sure I understand your question? do you want to know if you are logged in on a terminal? why not run %docker images command in the terminal and see if your images show up?
– noobuntu
Mar 15 '16 at 21:54
1
I want to know whether I am logged in to dockerhub registry in terminal. I thought the images are local, so it will just show the local images, not the dockerhub images.
– Ville Miekk-oja
Mar 15 '16 at 21:56
1
I believe once you are logged into docker, you are connected to your dockerhub registry. I don't think there is a separate login
– noobuntu
Mar 15 '16 at 22:01