How can I tell if I'm logged in to a private Docker registry from a script?

后端 未结 7 1101
粉色の甜心
粉色の甜心 2021-02-04 23:59

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

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-05 00:39

    if docker login worked, you will find a .docker folder on your home directory (~/.docker/), with a config.json file with credentials in it.

    otherwise you would get an error login in.

    Note: docker determine what credentials to use by looking at the registry name:

    if you do

    docker pull myregistry.com/myimage:tag

    docker will look if you're logged in, and if not will check if you have the credentials for the registry myregistry.com and login with those.

    If not you will get a permission error

提交回复
热议问题