I am newbie to the scala world, I try to run this project to understand the Scala Rest Play workflow : https://developer.lightbend.com/guides/play-rest-api/index.html
I am able to run this project successfully using the sbt run
command
/scala/play-scala-rest-api-example$ sbt run
[info] Loading settings for project play-scala-rest-api-example-build from plugins.sbt ...
[info] Loading project definition from /home/scala/play-scala-rest-api-example/project
[info] Loading settings for project root from build.sbt ...
[info] Loading settings for project docs from build.sbt ...
[info] Set current project to play-scala-rest-api-example (in build file:/home/dominic/scala/play-scala-rest-api-example/)
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Enter to stop and go back to the console...)
I try to put this project inside docker
FROM ubuntu:latest
MAINTAINER group
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y software-properties-common && \
add-apt-repository ppa:webupd8team/java -y && \
apt-get update && \
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
apt-get install -y oracle-java8-installer && \
apt-get clean
RUN echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
RUN apt-get update
RUN apt-get install -y sbt=1.2.8
COPY ./ ./
WORKDIR ./play-scala-rest-api-example
CMD ["sbt","run"]
It is build successfully as docker image
But when I run this docker image, It is opening the port : 9000 (as we run without docker) and immediately the port is closing like below
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0.0.0.0:9000
(Server started, use Enter to stop and go back to the console...)
[info] p.c.s.AkkaHttpServer - Stopping server...
[success] Total time: 614 s, completed Feb 5, 2019 5:11:56 AM
[INFO] [02/05/2019 05:11:56.196] [Thread-2] [CoordinatedShutdown(akka://sbt-web)] Starting coordinated shutdown from JVM shutdown hook
My query is why it is shutting down when I run in docker? How to run this forever?
docker run -it -p 9000:9000 <your other options> <your-image>
) ?-it
option, otherwise your standard input will not be connected to your container, and then the server will immediately stop after it has started.