Reputation: 32304
I have an image that is built using this dockerfile.
# vi Dockerfile
FROM openjdk:8
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
I can login to container in interactive mode and type this command that works as expected.
java -jar /usr/src/myapp/dist/some.jar
But if I add this line to Dockerfile, I get an error:
CMD ["/usr/src/myapp/dist/some.jar", "java"]
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \" -jar /usr/src/myapp/dist/some.jar\": stat -jar /usr/src/myapp/dist/some.jar: no such file or directory".
How do I add the java command to dockerfile?
Upvotes: 0
Views: 245
Reputation: 43798
Why don't you use the same command as you would type in?
CMD ["java", "-jar", "/usr/src/myapp/dist/some.jar"]
Upvotes: 1
Reputation: 146630
You are using thus wrongly. It should be
CMD ["java", "-jar", "/usr/src/myapp/dist/some.jar"]
or
CMD java -jar /usr/src/myapp/dist/some.jar
Upvotes: 1