有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Docker:Play framework应用程序退出,代码为0

我正在对scala play框架应用程序进行对接。Docker生成成功,但Docker运行退出,代码为0

user-service | [info] Loading project definition from /app/project
user-service | [info] Set current project to user-service (in build file:/app/)
user-service | 
user-service | SLF4J: Class path contains multiple SLF4J bindings.
user-service | SLF4J: Found binding in [jar:file:/app/lib/logback-classic-1.2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
user-service | SLF4J: Found binding in [jar:file:/root/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
user-service | SLF4J: Found binding in [jar:file:/root/.ivy2/cache/org.slf4j/slf4j-nop/jars/slf4j-nop-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
user-service | SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
user-service | SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
user-service | --- (Running the application, auto-reloading is enabled) ---
user-service | 
user-service | [info] p.c.s.AkkaHttpServer - Listening for HTTP on /0.0.0.0:9004
user-service | 
user-service | (Server started, use Enter to stop and go back to the console...)
user-service | 
user-service | [info] p.c.s.AkkaHttpServer - Stopping server...
user-service | 
user-service | [success] Total time: 4 s, completed Apr 2, 2020 10:40:20 AM
user-service exited with code 0

我的Dockerfile

FROM sshek2019/docker-scala

WORKDIR '/app'

COPY

EXPOSE 9004

CMD ["sbt", "run"]

我的docker编写文件

version: "3.7"

services:
  api:
    build: .
    container_name: user-service
    expose:
      - "9004"
    ports:
      - "9004:9004"

共 (1) 个答案

  1. # 1 楼答案

    你的配置说明你的应用程序中的on enter/closed std应该被关闭,打开后立即终止。应该为docker映像禁用development mode

    例如,您可以使用test instance mode

    CMD ["sbt", "runProd"]
    

    然而,您应该在Docker中以交互模式运行sbt,这样std in就不会立即关闭

    docker run  it ...