Docker Cannot Launch Java Application

I have the following project directory structure:

myapp/ grails-app/ (its a grails app, derrrr) target/ myapp.jar (built by grails) myapp.yml 

... where target/myapp.jar is an executable JAR (actually a standalone web application using the built-in Jetty), and where myapp.yml is the configuration file needed at startup.

Here is my Dockerfile :

 FROM java:8 MAINTAINER My Name < myname@example.com > WORKDIR / ADD ./target/myapp.jar /myapp.jar ADD ./myapp.yml /myapp.yml EXPOSE 8080 CMD ["java", "-jar myapp.jar myapp.yml"] 

Then I create the image using docker build -t myapp . . It works successfully. Then I try to run the image through docker run myapp and get:

 Unrecognized option: -jar myapp.jar myapp.yml Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. 

Any idea what might be wrong here, and what do I need to do to fix it or fix it?

+5
source share
1 answer

You pass all your parameters as one parameter, but they are different. You have to do

 CMD ["java", "-jar", "myapp.jar", "myapp.yml"] 
+8
source

Source: https://habr.com/ru/post/1232999/


All Articles