我将我的凭证存储在访问私有注册表的 ~/.docker/config.json
文件。因此,我可以简单地运行 docker login <url>
而没有明确说明我的凭证。是否有办法使用 docker-py?
我只找到这个 登录 方法,它总是需要一个用户名。使用 cli,我只需要注册表主机名(和 ~/.docker/config.json
文件和这个注册表的auth token)。)
这是否可以实现?T
以下是 login
的方法和选项。
login()
Authenticate with a registry. Similar to the docker login command.
Parameters:
username (str) – The registry username
password (str) – The plaintext password
email (str) – The email for the registry account
registry (str) – URL to the registry. E.g. https://index.docker.io/v1/
reauth (bool) – Whether or not to refresh existing authentication on the Docker server.
dockercfg_path (str) – Use a custom path for the Docker config file (default $HOME/.docker/config.json if present, otherwise``$HOME/.dockercfg``)
而据此。dockercfg_path,是存在于你可以使用该文件的登录方式。
从实验来看,虽然,这个 username
对于保存在.dockerconfig.json中的凭证是被忽略的,所以我只用了一个随机值就可以了。