AWS Beanstalk docker 图像自动更新不起作用

AWS Beanstalk docker image automatic update doesn't work

我有一个 node.js 应用程序打包在 docker 图像中托管在 public 存储库中。

我已经在 AWS Beanstalk docker 应用程序中成功部署了该映像。 问题是当我更新 public 存储库中的图像时,我希望 Beanstalk 应用程序能够自动更新,正如以下配置所建议的那样。

Dockerrun.aws.json:

{
  "AWSEBDockerrunVersion": "1",
  "Image": {
    "Name": "peveuve/dynamio-payment-service",
    "Update": "true"
  },
  "Ports": [
    {
      "ContainerPort": "8000"
    }
  ],
  "Logging": "/var/log/dynamio"
}

Dockerfile非常简单:

FROM node:4.2.1-onbuild
# Environment variables
ENV NODE_ENV test
ENV PORT 8000
# expose application port outside
EXPOSE $PORT

Amazon 文档对此非常清楚:

Optionally include the Update key. The default value is "true" and instructs Elastic Beanstalk to check the repository, pull any updates to the image, and overwrite any cached images.

但我必须通过上传新版本的 Dockerrun.aws.json 描述符来手动更新 Beanstalk 应用程序。我错过了什么?它应该像那样工作吗?

文档应该更清楚。他们说的是 update=true:

EBS 将在应用程序首次启动时先执行 docker pull,然后再执行 docker run。它不会持续轮询 docker hub。

相比之下,如果不先执行 docker pull 就发出 docker run 将始终使用该机器的本地存储版本,这可能并不总是最新的。

为了实现您想要的效果,您需要设置一个 webhook on Docker Hub,它调用您控制的应用程序,重建您的 ELB 应用程序。

您可以使用 aws command-line 工具触发更新:

aws elasticbeanstalk update-environment --application-name [your_app_name] --environment-name [your_environment_name] --version-label [your_version_label]

您指定包含 Dockerrun.aws.json 文件的版本,这样就不会将新版本添加到应用程序中。在这种情况下,Dockerrun 文件作为应用程序的 "source",但它只告诉 aws 拉取 docker 图像,因此在 Elastic Beanstalk 中为应用程序创建新版本是多余的(除非您在 Dockerrun 文件中使用了特别标记的 docker 图像)

链接:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_image.html http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_UpdateEnvironment.htm