1
FROM openjdk:8
LABEL maintainer="test"
EXPOSE 8080
ADD test-demo.jar assembly.jar
ENTRYPOINT ["java","-jar","assembly.jar"]

The container i start with this docker file exits soon after it starts. Please advice what to do to keep this running.

lxg
  • 12,375
  • 12
  • 51
  • 73
Chinmayee Pdas
  • 145
  • 1
  • 2
  • 11
  • It might be a problem with the jar itself. Did you try running `java -jar assembly.jar` from the command line to make sure that doesn't exit? Once you get that working, then you can run the docker image. – nareddyt Jul 22 '18 at 18:01
  • try `docker logs ` to see what went wrong. If you are not sure aobut the ID, try `docker ps -a` to see all contianers you had – buddy123 Jul 22 '18 at 18:01

1 Answers1

0

You need to make sure a java -jar assembly.jar will keep being active as a foreground process, or said main process would exit, and with it the docker container itself.

You should wrap the java -jar call in its own script, which allows various ways to keep that script alive, as described here.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250