执行“eb local run”时出现“注册表配置无效”错误
Posted
技术标签:
【中文标题】执行“eb local run”时出现“注册表配置无效”错误【英文标题】:"Invalid configuration for registry" error when executing "eb local run" 【发布时间】:2017-10-17 02:02:04 【问题描述】:我认为这是一个很容易解决的问题,但我似乎无法解决它!我花了很多时间在 Google/SO 上寻找任何线索,但找不到解决方案。
执行eb local run
时,我收到此错误:
注册表配置无效
$ eb local run
ERROR: InvalidConfigFile :: Invalid configuration for registry 12345678.dkr.ecr.eu-west-1.amazonaws.com
我Dockerrun.aws.json
中的图片行如下:
"AWSEBDockerrunVersion": 2,
"volumes": [
"name": "frontend",
"host":
"sourcePath": "/var/app/current/frontend"
,
"name": "backend",
"host":
"sourcePath": "/var/app/current/backend"
,
"name": "nginx-proxy-conf",
"host":
"sourcePath": "/var/app/current/config/nginx"
,
"name": "nginx-proxy-content",
"host":
"sourcePath": "/var/app/current/content/"
,
"name": "nginx-proxy-ssl",
"host":
"sourcePath": "/var/app/current/config/ssl"
],
"containerDefinitions": [
"name": "backend",
"image": "123456.dkr.ecr.eu-west-1.amazonaws.com/backend:latest",
"Update": "true",
"essential": true,
"memory": 512,
"mountPoints": [
"containerPath": "/app/backend",
"sourceVolume": "backend"
],
"portMappings": [
"containerPort": 4000,
"hostPort": 4000
],
"environment": [
"name": "PORT",
"value": "4000"
,
"name": "MIX_ENV",
"value": "dev"
,
"name": "PG_PASSWORD",
"value": "xxsaxaax"
,
"name": "PG_USERNAME",
"value": "
,
"name": "PG_HOST",
"value": "123456.dsadsau89das.eu-west-1.rds.amazonaws.com"
,
"name": "FE_URL",
"value": "http://develop1.com"
]
,
"name": "frontend",
"image": "123456.dkr.ecr.eu-west-1.amazonaws.com/frontend:latest",
"Update": "true",
"essential": true,
"memory": 512,
"links": [
"backend"
],
"command": [
"npm",
"run",
"production"
],
"mountPoints": [
"containerPath": "/app/frontend",
"sourceVolume": "frontend"
],
"portMappings": [
"containerPort": 3000,
"hostPort": 3000
],
"environment": [
"name": "REDIS_HOST",
"value": "www.eample.com"
]
,
"name": "nginx-proxy",
"image": "nginx",
"essential": true,
"memory": 128,
"portMappings": [
"hostPort": 80,
"containerPort": 3000
],
"links": [
"backend",
"frontend"
],
"mountPoints": [
"sourceVolume": "nginx-proxy-content",
"containerPath": "/var/www/html"
,
"sourceVolume": "awseb-logs-nginx-proxy",
"containerPath": "/var/log/nginx"
,
"sourceVolume": "nginx-proxy-conf",
"containerPath": "/etc/nginx/conf.d",
"readOnly": true
,
"sourceVolume": "nginx-proxy-ssl",
"containerPath": "/etc/nginx/ssl",
"readOnly": true
]
],
"family": ""
【问题讨论】:
能否提供您的 docker 版本? 克里斯,你能确认我的回答是否有效吗? 【参考方案1】:您的 docker-registry 身份验证配置文件似乎已损坏。在您的家中,此文件 ~/.docker/config.json
应类似于:
"auths":
"https://1234567890.dkr.ecr.us-east-1.amazonaws.com":
"auth": "xxxxxx"
那是用命令docker login
生成的(与aws ecr get-login
有关)
检查一下。我这样说是因为你输入了一个例外here:
for registry, entry in six.iteritems(entries):
if not isinstance(entry, dict):
# (...)
if raise_on_error:
raise errors.InvalidConfigFile(
'Invalid configuration for registry 0'.format(registry)
)
return
【讨论】:
我能够手动编辑我的config.json
文件并将aws ecr get-login
命令中的密码添加为auth
键的值并成功运行eb local
命令。谢谢!【参考方案2】:
这是由于当前版本的 awsebcli
工具中的依赖项过时所致。他们固定版本“docker-py (>=1.1.0,docker-py 是第一个正确支持最新凭证帮助程序格式的版本,在 AWS EB CLI 开发人员更新 docker-py
以使用 2.4.0 (https://github.com/docker/docker-py/releases/tag/2.4.0) 之前,这将保持损坏。
【讨论】:
【参考方案3】:首先是它不是有效的 json,PG_USERNAME 字段没有封闭引号。
"name": "PG_USERNAME",
"value": "
,
应该是
"name": "PG_USERNAME",
"value": ""
,
接下来要检查的是查看您的 Beanstalk 实例配置文件是否可以访问 ecr 注册表。
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/iam-instanceprofile.html
指定现有 Docker 存储库上的 Docker 基础映像,您将从该存储库构建 Docker 容器。为 Docker Hub 上的图像指定 Name 键的值,格式为 /,对于其他站点,则为 //。
当您在 Dockerrun.aws.json 文件中指定一个映像时,您的 Elastic Beanstalk 环境中的每个实例都会在该映像上运行 docker pull 并运行它。可选地包括更新键。默认值为“true”,指示 Elastic Beanstalk 检查存储库、拉取对映像的任何更新并覆盖所有缓存的映像。
使用 Dockerfile 时,不要在 Dockerrun.aws.json 文件中指定 Image 键。 .Elastic Beanstalk 将始终构建和使用 Dockerfile 中描述的映像(如果存在)。
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_image.html
测试以确保您也可以在 Elasticbeanstalk 之外访问您的 ecr。
$ docker pull aws_account_id.dkr.ecr.us-west-2.amazonaws.com/amazonlinux:latest
latest: Pulling from amazonlinux
8e3fa21c4cc4: Pull complete
Digest: sha256:59895a93ba4345e238926c0f4f4a3969b1ec5aa0a291a182816a4630c62df769
Status: Downloaded newer image for aws_account_id.dkr.ecr.us-west-2.amazonaws.com/amazonlinux:latest
http://docs.aws.amazon.com/AmazonECR/latest/userguide/docker-pull-ecr-image.html
【讨论】:
以上是关于执行“eb local run”时出现“注册表配置无效”错误的主要内容,如果未能解决你的问题,请参考以下文章
amazon elastic beanstalk eb local run 在我的机器上出现问题