AWS CodePipeline连接EFS到多容器Docker弹性豆茎失败

问题描述 投票:0回答:1

我使用AWS CodePipeline在Elastic Beanstalk上部署一个多容器docker应用。该应用需要从EFS附加一个文件系统作为挂载卷。为了附加并访问该卷,我似乎需要重新启动docker。这在这个问题中得到了解释。使用AWS EFS与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个回答
0
投票

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

你能不能确认一下你是否通过任何EB扩展来重启dockerecs-agent,因为这可能会妨碍EB的正常启动过程?

如果你使用EB扩展来重启docker,请在 "post-deploy "阶段使用 "hooks "来重启,这不会影响你的bootstrap进程。以下是你可以使用的常见钩子[1]。在这个链接[2]中也有一些例子。

参考文献

[1] https:/docs.aws.amazon.comelasticbeanstalklatestdgcustom-platform-hooks.html。

[2] https:/github.comequivalentscrapbook2blobmasterarchiveblogs2016-08-22-aws-elasticbeanstalk-hooks.md。

© www.soinside.com 2019 - 2024. All rights reserved.