我在DockerHub上有一个私有存储库,我正在尝试将其与ECS一起部署。我总是得到以下错误:
Unable to decode provided docker credentials module="ecs credentials" type="dockercfg"
或者如果我尝试使用类型docker:
Unable to decode provided docker credentials module="ecs credentials" type="docker"
我已经尝试了ECS开发者论坛上提到的所有可能性。
我试过了:
ECS_ENGINE_AUTH_TYPE=dockercfg
ECS_ENGINE_AUTH_DATA='{"https://index.docker.io/v1/":{"auth":"<token>","email":"<email>"}}'
我也试过:
ECS_ENGINE_AUTH_TYPE=docker
ECS_ENGINE_AUTH_DATA='{"https://index.docker.io/v1/":{"username":"<username>","password":"<password>","email":"<email>"}}'
此外(因为https://godoc.org/github.com/aws/amazon-ecs-agent/agent/engine/dockerauth):
ECS_ENGINE_AUTH_TYPE=docker
ECS_ENGINE_AUTH_DATA='{"https://index.docker.io/v1/<username>":{"username":"<username>","password":"<password>","email":"<email>"}}'
我还尝试在JSON周围不使用"并使用"。。同样的效果。我总是犯同样的错误。
我应该补充一点,我正在从S3容器中获得ecs.config,它运行良好。我还手动重新键入了文件,以防在下载文件时出现一些可疑的格式(尽管我不知道S3文件是以字节流的形式出现的)。
如果我SSH到实例并执行以下操作:
docker login --username=<username> --password=<password> --email=<email>
然后我可以成功地提取图像:docker pull A/B:latest
然而,即使在我登录之后(因此docker生成了~/.docker/config.json文件),我仍然会从ECS中得到同样的错误。
我应该提到更改ecs.config文件的所有操作如下所示:
- 将任务数更改为0
- 等待完成
sudo stop ecs
- 更改配置文件
sudo start ecs
- 将任务数更改为1
重复。。。
这变得非常令人沮丧。。这应该如何工作,或者自编写文档以来发生了什么变化?
如有任何帮助,我们将不胜感激。
编辑
我还尝试在/etc/ecs/ecs.config.JSON:中的JSON配置文件中设置docker-auth
{
"EngineAuthType": "docker",
"EngineAuthData": {
"https://index.docker.io/v1/": {
"username": "<me>",
"password": "<password>",
"email": "<email>"
}
}
}
这里描述了用于此操作的JSON配置:https://godoc.org/github.com/aws/amazon-ecs-agent/agent/config.这里的代码注释中也提到了这一点:https://github.com/aws/amazon-ecs-agent/blob/b197eddd9d5272eeac7dddaa2a84cc4c85522354/agent/engine/dockerauth/doc.go
更具体地说:
可以通过设置环境变量来设置这些关键点"ECS_ENGINE_AUTH_TYPE"one_answers"ECS_ENGINE_AUTH_DATA",或通过在位于配置的"ECS_AGENT_CONFIG_file_PATH"处的JSON配置文件中设置键"EngineAuthData"one_answers"EngineAuthType"(请参阅http://godoc.org/github.com/aws/amazon-ecs-agent/agent/config)
这又是一次,给出了相同的错误。。。
花了一些时间浏览ECS代理的代码之后(https://github.com/aws/amazon-ecs-agent)我意识到问题出在哪里。问题出在电子邮件字段,应该删除!
所以,简单回顾一下如何做到这一点:
您需要按照此处的说明进行操作:http://docs.aws.amazon.com/AmazonECS/latest/developerguide/private-auth.html.
但是,所有的示例都包括电子邮件字段。
ecs.config
应该是这样的:
ECS_ENGINE_AUTH_TYPE=dockercfg
ECS_ENGINE_AUTH_DATA={"https://index.docker.io/v1/":{"auth":"<your auth token>"}}
要在创建实例时从S3容器加载ecs.config
,请执行以下操作:http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html,特别是"在AmazonS3中存储ecs.config文件"one_answers"在启动时从AmazonS3加载ecs.cnfig文件"标题。