Reputation: 29567
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 the executable JAR (actually a self-contained web app running embedded Jetty), and where myapp.yml
is a config file required at startup.
Here is my Dockerfile
:
FROM java:8
MAINTAINER My Name <[email protected]>
WORKDIR /
ADD ./target/myapp.jar /myapp.jar
ADD ./myapp.yml /myapp.yml
EXPOSE 8080
CMD ["java", "-jar myapp.jar myapp.yml"]
I then build the image with docker build -t myapp .
. It builds successfully I then try to run the image via 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 could be going wrong here, and what I need to do to fix this or troubleshoot it?
Upvotes: 10
Views: 12599
Reputation: 53553
You're giving all your parameters as one single parameter, but they are distinct. You should do
CMD ["java", "-jar", "myapp.jar", "myapp.yml"]
Upvotes: 18