"注册表的配置无效"执行" eb本地运行时出错"

时间:2017-05-17 14:28:42

标签: amazon-web-services docker elastic-beanstalk aws-cli eb

我认为这是一个很容易解决的问题,但我似乎无法解决它!我花了很多时间在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": ""
}

3 个答案:

答案 0 :(得分:4)

您的docker-registry auth配置文件似乎已损坏。在您的家中,此文件~/.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 {}

答案 1 :(得分:3)

这是由于当前版本的awsebcli工具中存在过时的依赖项。他们固定版本“docker-py(> = 1.1.0,< = 1.7.2)”,它不支持较新的凭证助手格式。最新版本的docker-py是第一个正确支持最新凭据帮助程序格式的版本,直到AWS EB CLI开发人员更新docker-py以使用2.4.0(https://github.com/docker/docker-py/releases/tag/2.4.0),这将继续打破

答案 2 :(得分:2)

首先,它是无效的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并运行它。 (可选)包括Update键。默认值为" 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