【问题标题】:AWS CodePipeline Fails attaching EFS to Multicontainer Docker Elastic BeanstalkAWS CodePipeline 无法将 EFS 附加到多容器 Docker Elastic Beanstalk
【发布时间】:2020-08-11 07:03:41
【问题描述】:

我使用 AWS CodePipeline 在 Elastic Beanstalk 上部署多容器 docker 应用程序。该应用程序需要从 EFS 附加文件系统作为已安装的卷。为了附加并访问该卷,看来我需要重新启动 docker。这个问题解释了这一点:Using AWS EFS with Docker。虽然我可以根据这些说明成功附加文件系统,但我的部署有时会“失败”并出现以下错误:

Action execution failed Deployment completed, but with errors: ECS task stopped due to: Task failed to start.  Failed to start ECS task: arn:aws… is STOPPED.

在这些情况下,应用程序成功部署,并且功能齐全,但我收到一条失败消息,因为在检查期间 docker 尚未重新启动。

发生这种情况时,我在 Beanstalk 日志中看到以下内容:

-------------------------------------
/var/log/ecs/ecs-init.log
-------------------------------------
2020-04-27T15:06:41Z [INFO] pre-start
2020-04-27T15:06:44Z [INFO] start
2020-04-27T15:06:44Z [INFO] No existing agent container to remove.
2020-04-27T15:06:44Z [INFO] Starting Amazon Elastic Container Service Agent
2020-04-27T15:07:20Z [INFO] Agent exited with code 0
2020-04-27T15:07:20Z [INFO] Error connecting to docker, backing off for 1.14777941s, error: Get http://unix.sock/v1.25/version: dial unix /var/run/docker.sock: connect: no such file or directory
2020-04-27T15:07:21Z [INFO] Error connecting to docker, backing off for 2.282153551s, error: Get http://unix.sock/v1.25/version: dial unix /var/run/docker.sock: connect: no such file or directory
2020-04-27T15:07:23Z [INFO] post-stop
2020-04-27T15:07:23Z [INFO] Cleaning up the credentials endpoint setup for Amazon Elastic Container Service Agent
2020-04-27T15:07:23Z [INFO] pre-start
2020-04-27T15:07:23Z [INFO] start
2020-04-27T15:07:23Z [INFO] Container name: /ecs-agent
2020-04-27T15:07:23Z [INFO] Removing existing agent container ID:
2020-04-27T15:07:23Z [INFO] Starting Amazon Elastic Container Service Agent

有没有办法防止这些错误的失败?

【问题讨论】:

    标签: amazon-web-services amazon-elastic-beanstalk aws-codepipeline amazon-efs


    【解决方案1】:

    问题似乎是 ecs-agent 启动时 docker daemon 没有运行。 Elasticbeanstalk 有自己的方式来管理 docker daemon 和 ecs-agent 启动,除非手动/自动干预。

    您能否确认您是否通过任何 EB 扩展重新启动 docker/ecs-agent,因为它可能会妨碍 EB 正常引导过程?

    如果您使用 EB 扩展来启动/重新启动 docker,请在“部署后”阶段使用不会影响您的引导过程的“钩子”执行此操作。以下是您可以使用的常用钩子 [1]。此链接 [2] 上也提供了一些示例。

    参考资料:

    [1]https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/custom-platform-hooks.html

    [2]https://github.com/equivalent/scrapbook2/blob/master/archive/blogs/2016-08-22-aws-elasticbeanstalk-hooks.md

    【讨论】:

      猜你喜欢
      • 2017-07-26
      • 2021-11-25
      • 2020-07-23
      • 2015-06-20
      • 2020-06-17
      • 2020-11-14
      • 2015-05-01
      • 2015-03-13
      • 2018-12-12
      相关资源
      最近更新 更多