Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python docker sdk登录ecr注册表不会';I don’我没有按预期工作_Python_Docker_Dockerpy - Fatal编程技术网

使用python docker sdk登录ecr注册表不会';I don’我没有按预期工作

使用python docker sdk登录ecr注册表不会';I don’我没有按预期工作,python,docker,dockerpy,Python,Docker,Dockerpy,假设我已经在一个名为creds的对象中从boto获得ecr凭据,当我这样做时: client = from_env() client.login(creds.username, password=creds.password, registry=creds.endpoint) 我得到: {u'IdentityToken': u'', u'Status': u'Login Succeeded'} {'_auth_configs': {'auths': {'registry_i_just_log

假设我已经在一个名为creds的对象中从boto获得ecr凭据,当我这样做时:

client = from_env()
client.login(creds.username, password=creds.password, registry=creds.endpoint)
我得到:

{u'IdentityToken': u'', u'Status': u'Login Succeeded'}
{'_auth_configs': {'auths': {'registry_i_just_logged_into': {'email': None,
'password': 'xxxxxxxxxxxxx',
'serveraddress': 'registry_i_just_logged_into',
'username': 'xxxxxxx'},
u'some_other_registry': {},
'credsStore': u'osxkeychain'}
.... (etc, etc)
到目前为止棒极了!我检查:

client.api.__dict__
我得到:

{u'IdentityToken': u'', u'Status': u'Login Succeeded'}
{'_auth_configs': {'auths': {'registry_i_just_logged_into': {'email': None,
'password': 'xxxxxxxxxxxxx',
'serveraddress': 'registry_i_just_logged_into',
'username': 'xxxxxxx'},
u'some_other_registry': {},
'credsStore': u'osxkeychain'}
.... (etc, etc)
到目前为止,一切都很好。但当我这样做的时候:

client.images.pull("registry_i_just_logged_into/some_repo", tag="latest")
或者当我这样做时(从命令行):

我总是得到:

Error response from daemon: pull access denied for some_repo, repository does not exist or may require 'docker login'
尽管事实是,如果我这样做(使用与我登录时相同的用户名和密码):

没问题

因此,我假设这是解决使用哪个注册表的顺序的问题,但是如果该键已经存在于_auth_configs中,docker sdk似乎应该处理这个问题

我做错了什么

谢谢

rm-rf~/.docker/config.json

: 从
~/.docker/config.json

说明: 可能您已经尝试登录。因此,Docker config.json具有
credstore
auths
credstore
属性。 例如:


token=client.get\u authorization\u token()
返回base64编码的令牌。因此,要成功登录,您需要对其进行解码

import docker
import boto3
import base64

docker_client = docker.from_env()
client = boto3.client('ecr', aws_access_key_id="xyz", aws_secret_access_key="abc", region_name="ap-south-1")
token = client.get_authorization_token()
docker_client.login(username="AWS", password=base64.b64decode(token["authorizationData"][0]["authorizationToken"]).decode().split(":")[1], registry="xxxx.dkr.ecr.ap-south-1.amazonaws.com")
会回来的

{'IdentityToken': '', 'Status': 'Login Succeeded'}

这是可行的——但有没有办法避免重复删除文件?至少在我的情况下,这似乎并不可行。
{'IdentityToken': '', 'Status': 'Login Succeeded'}