【问题标题】:Dockerrun.aws.json file for private dockerhub image用于私有 dockerhub 映像的 Dockerrun.aws.json 文件
【发布时间】:2016-11-07 20:12:56
【问题描述】:

我正在尝试将使用 Docker 构建的 rails 应用程序部署到 Elastic Beanstalk 的多容器服务。我的 Dockerrun.aws.json 目前看起来像:

{
  "AWSEBDockerrunVersion": 2,
  "volumes": [
    {
      "name": "myapp",
      "host": {
        "sourcePath": "/var/app/current"
      }
    },
    {
      "name": "myapp-redis",
      "host": {
        "sourcePath": "/var/app/current/myapp-redis"
      }
    },
    {
      "name": "myapp-postgres",
      "host": {
        "sourcePath": "/var/app/current/myapp-postgres"
      }
    }
  ],
  "authentication": {
    "bucket": "myapp",
    "key": "config.json"
  },
  "containerDefinitions": [
    {
      "name": "redis",
      "image": "redis:3.0.5",
      "environment": [
        {
          "name": "Container",
          "value": "redis"
        }
      ],
      "portMappings": [
        {
          "hostPort": 6379,
          "containerPort": 6379
        }
      ],
      "essential": true,
      "memory": 128,
      "mountPoints": [
        {
          "sourceVolume": "myapp-redis",
          "containerPath": "/var/lib/redis/data",
          "readOnly": false
        }
      ]
    },
    {
      "name": "postgres",
      "image": "postgres:9.4.5",
      "environment": [
        {
          "name": "Container",
          "value": "postgres"
        }
      ],
      "portMappings": [
        {
          "hostPort": 5432,
          "containerPort": 5432
        }
      ],
      "essential": true,
      "memory": 128,
      "mountPoints": [
        {
          "sourceVolume": "myapp-postgres",
          "containerPath": "/var/lib/postgresql/data",
          "readOnly": false
        }
      ]
    },
    {
      "name": "myapp",
      "image": "myrepo/myapp:latest",
      "environment": [
        {
          "name": "Container",
          "value": "myapp"
        }
      ],
      "essential": true,
      "memory": 128,
      "mountPoints": [
        {
          "sourceVolume": "myapp",
          "containerPath": "/myapp",
          "readOnly": false
        }
      ]
    }
  ]
}

我的config.json 文件位于存储桶myapp/config.json 中,格式如下:

{
  "https://index.docker.io/v1/": {
    "auth": "mylongauthtokenhere",
    "email": "me@myemail.com"
  }
}

当我指向 "image": "myrepo/myapp:latest", 行的公共存储库时,此设置有效,但是当我尝试使用此配置进行初始化时,我收到错误:err="Error: image myrepo/myapp:latest not found"ERROR [Instance: i-913b2004] Command failed on instance. Return code: 1 Output: 'Failed to start ECS task after retrying 2 times.'

我还尝试了几种不同的方式配置 config.json,但没有成功。对此的任何帮助将不胜感激!

【问题讨论】:

  • 明确一点,当您使用此配置指向公共存储库时,它可以工作,但如果您将其指向私有存储库,则会出现错误(其他一切都相同)?
  • 是的,据我所知,唯一挂断的就是这是一个私人仓库。
  • 你能把auth的完整内容我想看看它嵌套了多远吗?您的配置来自 1.7 docker 还是 1.6 及更早版本?
  • 我在我的机器上使用 docker 1.10.3。 EB 仪表板显示 1.9.1
  • 查看我帖子的更新。 EB 仍然想要旧格式的 auth 文件,而不是 docker 1.7 或更高版本生成的文件。

标签: amazon-web-services docker amazon-elastic-beanstalk


【解决方案1】:

更新:OP 找到了所需的特定角色。这 aws-elasticbeanstalk-ec2-role 需要 AmazonS3ReadOnlyAccess 政策。

EB 通过服务角色运行。这些角色需要被授予适当的权限才能出去并从 S3 中获取凭证文件:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts-roles.html

另外,我猜你在本地使用 Docker 1.7 或更高版本。

Docker 1.7+ 登录会生成一个凭证文件config.json,如下所示:

{
 "auths" :
 {
    "server" :
   {
      "auth" : "auth_token",
      "email" : "email"
    }
   }
 } 

Elastic Beanstalk 过去只需要像这样的旧配置对象格式:

 {
    "server" :
   {
      "auth" : "auth_token",
      "email" : "email"
    }
   }

注意到缺少的外部身份验证块了吗?

或者,如果您在 OP EB 中指出使用的是 docker 1.9.1,则 ElasticBeanstalk 期待更新的格式。

您可以尝试编辑此文件并重新上传到 EB。详情见本页底部:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.container.console.html#docker-images-private

【讨论】:

  • 这是我的文件目前的样子,对吧?正如我的问题的第二个代码块中所述?还是看起来还是不对?
  • @Raskolnikov 尝试做相反的事情,将外部身份验证块添加到 json。他们的文档是出了名的古怪,也许现在他们接受了更新的配置格式
  • 好的,现在试试
  • 嗯,我的 EB 仪表板使用 docker 1.11.1 显示,但我使用旧格式的配置文件
  • @Raskolnikov 太棒了!我有一种感觉,如果这不是一个简单的 json 配置格式问题,那就是没有设置正确的服务角色——我发现角色和权限是 AWS 中最具挑战性的一个领域。如果 EB 在它遇到的确切问题和原因上更早一点,那也很好。我已更新我的答案,将检查您的服务角色的建议移至顶部,并指出您发现问题的确切角色。
猜你喜欢
  • 2020-07-28
  • 2019-08-21
  • 1970-01-01
  • 1970-01-01
  • 2018-11-21
  • 2019-08-05
  • 1970-01-01
  • 2018-10-14
  • 2019-01-27
相关资源
最近更新 更多