【问题标题】:Docker with Spring Boot application stuck at AnnotationConfigServletWebServerApplicationContext on RaspberryPi带有 Spring Boot 应用程序的 Docker 卡在 RaspberryPi 上的 AnnotationConfigServletWebServerApplicationContext
【发布时间】:2019-01-29 04:32:12
【问题描述】:

我要做的是通过 docker-compose 在 docker 容器 (openjdk:8-jre) 中运行简单的 Spring Boot 应用程序。该代码在我的机器(macbook pro)上运行良好。问题是当我试图用 raspbian 在我的树莓派上运行相同的 docker 容器时。它在登录Tomcat initialized with port(s): 8080 (http) 之前就卡住了。 带有 spring 应用程序的容器只执行 java -jar 并使用我的单页应用程序为我的另一个容器(在端口 8888 上)公开端口 8080。有没有人遇到过类似的问题或知道如何解决这个问题?

以下是在 raspberrypi 上运行容器的日志: wfeservices | . ____ _ __ _ _ wfeservices | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ wfeservices | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ wfeservices | \\/ ___)| |_)| | | | | || (_| | ) ) ) ) wfeservices | ' |____| .__|_| |_|_| |_\__, | / / / / wfeservices | =========|_|==============|___/=/_/_/_/ wfeservices | :: Spring Boot :: (v2.0.3.RELEASE) wfeservices | wfeservices | 2018-08-22 20:36:24 - Starting Application v1.0-SNAPSHOT on 4b7fcb7b344c with PID 7 (/wfeservices.jar started by root in /) wfeservices | 2018-08-22 20:36:24 - No active profile set, falling back to default profiles: default wfeservices | 2018-08-22 20:36:28 - Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@1412c2f: startup date [Wed Aug 22 20:36:28 UTC 2018]; root of context hierarchy

【问题讨论】:

  • 您是否尝试过使用--debug 甚至--trace 启动您的应用程序?顺便说一句,对于像 Raspberry Pi 这样的小型环境,我建议使用 Jetty 而不是 Tomcat,因为它更轻一些。 Spring 启动阶段是 CPU 和 IO 密集型的 - 可能是 Pi 需要很长时间。
  • 另外,请注意,Java 9 之前的任何东西本身都不支持容器化,这意味着 JVM 可能会设置 更高的 CPU/IO/内存限额/初始值比它应该的(即主机系统,而不是分配给容器的系统)。
  • 看起来它是在我构建和运行 docker-compose up --build 并带有额外标志 -d(在后台运行)时开始的。然后我可以在日志中看到 spring boot 应用程序在 200 秒后启动。当我不在后台运行时,它卡在root of context hierarchy
  • 您是否以任何方式(cpu、内存等)限制 docker 容器?
  • @user991710 没有限制

标签: java spring docker spring-boot docker-compose


【解决方案1】:

我在 AWS ECS 上遇到了完全相同的问题,然后我意识到我的内存太少了,所以我将内存增加到 4096 兆字节并且它起作用了。

【讨论】:

    猜你喜欢
    • 2018-12-05
    • 2017-04-07
    • 2018-02-02
    • 2020-05-29
    • 2018-03-08
    • 2020-03-12
    • 2021-07-04
    • 1970-01-01
    • 2016-08-07
    相关资源
    最近更新 更多