在Docker中以开发人员模式运行Play应用程序

时间:2019-05-06 19:03:33

标签: docker playframework sbt

我想在开发过程中使用docker。好舒服但是在以开发人员模式启动后,请关闭应用程序。

我有docker-compose来制作游戏框架和postgres。

version: '3.7'
services:
  postgres:
    container_name: postgres
    image: postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: db
      POSTGRES_USER: user_role
      POSTGRES_PASSWORD: pass
    volumes:
    - ${HOME}/docker/volumes/postgres:/var/lib/postgresql/data
    ports:
    - "5432:5432"
    networks:
      - my-net
  scala-back:
    container_name: scala-back
    image: hseeberger/scala-sbt
    restart: unless-stopped
    volumes:
    - ivy:/root/.ivy2
    - type: bind
      source: .
      target: /app
    command: /bin/bash -c 'cd /app && sbt run'
    ports:
      - "80:9000"
    networks:
      - my-net
networks:
  my-net:
    name: my-net
volumes:
  ivy:

docker-compose up之后,我得到了

scala-back    | --- (Running the application, auto-reloading is enabled) ---
scala-back    | 
scala-back    | [info] p.c.s.AkkaHttpServer - Listening for HTTP on /0.0.0.0:9000
scala-back    | 
scala-back    | (Server started, use Enter to stop and go back to the console...)
scala-back    | 
scala-back    | [info] p.c.s.AkkaHttpServer - Stopping server...
scala-back    | [info] p.a.h.EnabledFilters - Enabled Filters (see <https://www.playframework.com/documentation/latest/Filters>):
scala-back    | 
scala-back    |     play.filters.headers.SecurityHeadersFilter
scala-back    |     play.filters.hosts.AllowedHostsFilter
scala-back    |     play.filters.cors.CORSFilter
scala-back    | 
scala-back    | [info] play.api.Play - Application started (Dev)
scala-back    | 
scala-back    | [success] Total time: 6 s, completed May 6, 2019 7:00:37 PM
scala-back    | [INFO] [05/06/2019 19:00:37.223] [Thread-3] [CoordinatedShutdown(akka://sbt-web)] Starting coordinated shutdown from JVM shutdown hook
scala-back exited with code 0

我在命令中尝试了screen -d -m sbt run,但这没有帮助。

1 个答案:

答案 0 :(得分:0)

您应该以{{1​​}}开始容器。使用选项docker-compose up -d,您的容器将以分离模式启动,并且您的应用程序不应停止。