“重新启动应用程序服务器”后,Elastic Beanstalk Docker应用程序失败

时间:2016-07-17 23:47:54

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

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

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

  • eb init“test-app”
  • 创建一个简单的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之间的某种不兼容。

1 个答案:

答案 0 :(得分:0)

您应该将Health Report系统设置为Basic,或者使用.ebextensions设置负载均衡器,如下所述:

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