本文介绍了通过Python中的Docker API设置登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试Docker API python库,但未能获得成功,请仔细阅读文档.实际上,我正在尝试使用API​​登录到Docker.

I'm trying Docker API python library, but couldn't get a little success, have go through the docs.Actually I'm trying to login to docker using API.

这是我的python代码:

Here's my python Code:

import docker

config = os.path.join(BASE_DIR, 'IGui') + 'config.json'
client = docker.APIClient.login('username', '*******', '[email protected]','https://index.docker.io/v1/', config)

这是我收到的错误:

AttributeError at /gui/docker/
'str' object has no attribute '_auth_configs'
Request Method: POST
Request URL:    http://127.0.0.1:8000/gui/docker/
Django Version: 1.11.3
Exception Type: AttributeError
Exception Value:
'str' object has no attribute '_auth_configs'
Exception Location: /Users/abdul/IstioVirEnv/lib/python3.6/site-     packages/docker/api/daemon.py in login, line 128
Python Executable:  /Users/abdul/IstioVirEnv/bin/python
Python Version: 3.6.1

如何通过python中的API设置docker登录?请帮帮我!

how can I setup docker login through API in python? help me please!

推荐答案

我假定这是您要运行的命令: http://docker-py.readthedocs.io/en/stable/client.html#docker.client.DockerClient.login

I assume this is the command you are trying to run: http://docker-py.readthedocs.io/en/stable/client.html#docker.client.DockerClient.login

从文档中,我看到您传递的参数是:

From the docs, I see the parameters you pass are:

我不确定,可能是您使用的是模块的旧/新版本.尝试使用关键字参数.这可能有助于缩小范围.

I'm not sure, it could be you're using an older/newer version of the module. Try using keyword arguments. That might help narrow it down.

这篇关于通过Python中的Docker API设置登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:01