How can I tell whether or not I\'m logged in to a private Docker registry server from a script? In other words, has docker login some.registry.com
been run success
This is a bit hacky, but it works in most of the cases for me:
if ! grep -q "my.private.registry.com" ~/.docker/config.json ; then
docker login "my.private.registry.com"
fi
Basically, you search if there is a record of "my.private.registry.com" in ~/.docker/config.json
. However, if the session is expired, this check won't catch it.