【问题标题】:Cannot authenticate to Docker in Elastic Beanstalk through S3无法通过 S3 向 Elastic Beanstalk 中的 Docker 进行身份验证
【发布时间】:2017-06-30 05:53:48
【问题描述】:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_image.html#docker-singlecontainer-dockerrun-privaterepo

按照此处的说明从 Elastic Beanstalk 连接到私有 docker hub 容器,但它顽固地拒绝工作。似乎在 Docker 1.12 中调用 docker login 时生成的文件没有电子邮件属性,但听起来 aws 期望它,所以我创建了一个名为 dockercfg.json 的文件,如下所示:

{
    "https://index.docker.io/v1/": {
        "auth": "Y2...Fz",
        "email": "c...n@gmail.com"
    }
}

我的 Dockerrun.aws.json 文件的相关部分如下所示:

  "Authentication": {
    "Bucket": "elasticbeanstalk-us-west-2-9...4",
    "Key": "dockercfg.json"
  },

我已将文件上传到 S3 存储桶的根目录。为什么我仍然会收到Error: image c...6/w...t:23 not found. Check snapshot logs for details. 的错误消息,我确信名称是正确的,并且如果它是公共存储库,这将起作用。完整的错误如下。如果有影响,我将从 GitHub 使用 Circle CI 进行部署,很乐意提供所需的任何其他信息。

INFO: Deploying new version to instance(s).                         
WARN: Failed to pull Docker image c...6/w...t:23, retrying...
ERROR: Failed to pull Docker image c...6/w...t:23: Pulling repository docker.io/c...6/w...t
Error: image c...6/w...t:23 not found. Check snapshot logs for details.
ERROR: [Instance: i-06b66f5121d8d23c3] Command failed on instance. Return code: 1 Output: (TRUNCATED)...b-project
Error: image c...6/w...t:23 not found
Failed to pull Docker image c...6/w...t:23: Pulling repository docker.io/c...6/w...t
Error: image c...6/w...t:23 not found. Check snapshot logs for details. 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03build.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) 'i-06b66f5121d8d23c3'. Aborting the operation.
ERROR: Failed to deploy application.                                

ERROR: Failed to deploy application.

编辑:这是完整的 Dockerrun 文件。请注意,%BUILD_NUM% 只是一个 int,我可以验证它是否有效。

{
  "AWSEBDockerrunVersion": "1",
  "Authentication": {
    "Bucket": "elasticbeanstalk-us-west-2-9...4",
    "Key": "dockercfg.json"
  },
  "Image": {
    "Name": "c...6/w...t:%BUILD_NUM%",
    "Update": "true"
  },
  "Ports": [
    {
      "ContainerPort": "8080"
    }
  ]
}

编辑:另外,如果我将此 Docker Hub 容器公开,我已经验证了它是否有效。

【问题讨论】:

  • 你能发布整个 Dockerrun.aws.json 文件吗?
  • 是的,谢谢,刚刚做了
  • 一切似乎都是正确的。您能否确认 EB 具有访问该 S3 存储桶所需的所有 IAM 权限?
  • 仔细检查,我使用访问密钥的用户具有完全 S3 访问权限和完全 Elastic Beanstalk 访问权限
  • Check snapshot logs for details 那里面有什么?

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


【解决方案1】:

好的,让我们这样做;

查看同一个文档页面,

对于 Docker 1.6.2 及更早版本,docker login 命令会在 ~/.dockercfg 中以以下格式创建身份验证文件:

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

我明白了,你已经把这部分弄对了。请仔细检查以下案例;

1) 您是否在同一区域托管 S3 存储桶?

Amazon S3 存储桶必须与 使用它的环境。 Elastic Beanstalk 无法下载文件 来自其他区域托管的 Amazon S3 存储桶。

2) 您是否检查了所需的权限?

将 s3:GetObject 操作的权限授予 IAM 角色 实例配置文件。详情请见Managing Elastic Beanstalk Instance Profiles

3) 您的配置文件中有您的 S3 存储桶信息吗? (我想你也有这个)

Authentication (v1) 或 authentication (v2) 参数在您的 Dockerrun.aws.json 文件中。

看不到您的权限或您的环境区域,因此请仔细检查。 如果这不起作用,我会尽可能升级到 Docker 1.7+ 并使用相应的~/.docker/config.json 样式。

【讨论】:

  • 感谢您的建议,可悲的是,我犯了一个愚蠢的错误,即拥有 2 个 Dockerrun.aws.json 文件并编辑了错误的文件,因为无论我从未真正仔细检查过什么,我都遇到了身份验证问题。现在都解决了。
猜你喜欢
  • 1970-01-01
  • 2012-04-01
  • 2014-01-05
  • 1970-01-01
  • 1970-01-01
  • 2016-12-09
  • 2023-01-19
  • 2015-09-15
  • 2017-08-31
相关资源
最近更新 更多