【问题标题】:Elastic Beanstalk Docker App fails after "Restart App Servers"Elastic Beanstalk Docker 应用程序在“重新启动应用程序服务器”后失败
【发布时间】:2016-11-20 11:41:27
【问题描述】:

我正在尝试在 Elastic Beanstalk 中测试一个非常简单的 docker 应用程序。但是,我遇到了一个非常奇怪的问题,在我从我的 EB 应用程序环境中执行“重新启动应用程序服务器”之后,我的应用程序因“502 Bad Gateway”而失败。

我正在做以下事情......

  • eb 初始化“测试应用”
  • 创建一个简单的 Dockerfile...

{代码}

FROM ubuntu

RUN apt-get update -y && apt-get install -y apache2

EXPOSE 80

ENTRYPOINT ["/usr/sbin/apache2ctl","-DFOREGROUND"]

{代码}

  • eb 创建“test-app-dev-123”

应用程序已成功创建和部署,并正确响应 Web 请求。

但是,如果我尝试从 EB 控制台或从 aws cli 命令行重新启动应用程序服务器,它似乎可以工作,但是所有请求都会失败并出现 502 错误。

恢复的唯一方法是重新部署环境。

当它处于失败状态时,如果我使用“eb ssh”连接到主机,我可以看到 docker 容器不断尝试重新启动。它开始,然后几乎立即再次停止。但是,我可以从主机手动启动容器(使用 docker run...),它工作正常。

我试图让我的示例尽可能简单。除了单个 Dockerfile 之外,我的 eb 应用程序中没有任何内容。

我进行了更多调查,这看起来像是 EB 中的一个错误。我已经下载了日志,这就是它看起来开始出错的地方......

time="2016-07-18T01:51:08.119354030Z" level=error msg="devmapper: Error unmounting device 3244...ef18: invalid argument" 
time="2016-07-18T01:51:10.414373171Z" level=info msg="Layer sha256:968d...5a9 cleaned up" 
time="2016-07-18T01:51:11.023279947Z" level=error msg="devmapper: Error unmounting device e140...53366: invalid argument" 
time="2016-07-18T01:51:13.310053346Z" level=info msg="Layer sha256:968d...65a9 cleaned up" 
time="2016-07-18T01:51:13.911371884Z" level=error msg="devmapper: Error unmounting device c3f...6f: invalid argument" 
time="2016-07-18T01:51:25.369515769Z" level=error msg="Handler for DELETE /v1.23/containers/2c98ce28854f returned error: You cannot remove a running container 2c98...bb34. Stop the container before attempting removal or use -f" 
time="2016-07-18T01:51:25.414283268Z" level=error msg="Handler for DELETE /v1.23/images/3d39763a8ca1 returned error: conflict: unable to delete 3d39763a8ca1 (cannot be forced) - image is being used by running container 2c98ce28854f" 
time="2016-07-18T01:51:25.414503066Z" level=error msg="Handler for DELETE /v1.23/images/df34b0ea0bfb returned error: conflict: unable to delete df34b0ea0bfb (cannot be forced) - image has dependent child images" 
time="2016-07-18T01:51:25.414735070Z" level=error msg="Handler for DELETE /v1.23/images/c67665a031d2 returned error: conflict: unable to delete c67665a031d2 (cannot be forced) - image has dependent child images" 
time="2016-07-18T01:51:25.414947068Z" level=error msg="Handler for DELETE /v1.23/images/cf62323fa025 returned error: conflict: unable to delete cf62323fa025 (cannot be forced) - image has dependent child images" 
time="2016-07-18T02:35:45.291715871Z" level=info msg="Container 2c98...1bb34 failed to exit within 10 seconds of signal 15 - using the force" 
time="2016-07-18T02:42:53.063530940Z" level=info msg="Container 2c98ce...e1bb34 failed to exit within 10 seconds of signal 15 - using the force" 

在我看来,这似乎是 EB 和 Docker 之间的某种不兼容。

【问题讨论】:

  • 您是否在此堆栈中使用负载均衡器?
  • 我目前正在使用单个实例进行测试,但它似乎总是使用负载均衡器。
  • Ok 问题正在发生,因为您的 Docker 没有通过 ELB 中的健康检查,这就是它重新启动的原因。尝试一件事,将 ELB 中的健康检查从 http 更改为 TCP,然后尝试启动。
  • 感谢 @error2007s 我设法通过在控制台中将运行状况报告系统类型更改为“基本”来使其正常工作。
  • @user1751825 您应该将其发布为答案。

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


【解决方案1】:

您应该将运行状况报告系统设置为基本,或者使用 .ebextensions 设置负载平衡器,如下所述:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.elb.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-05
    • 2013-10-21
    • 2020-10-31
    • 2018-03-18
    • 1970-01-01
    • 2022-12-29
    • 1970-01-01
    • 2012-12-26
    相关资源
    最近更新 更多