0

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?

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

Why don't you use the same command as you would type in?

CMD ["java", "-jar", "/usr/src/myapp/dist/some.jar"]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.