Docker Community Forums

Share and learn in the Docker community.

OpenJDK cant deploy the simplest java app


(Fortblox) #1

HI, I’m new to dockers and I wanted to play around with a docker.
So far I have failed miserably…

I have a very simple app.jar file and this is my simple Dockerfile:

FROM openjdk:8-jre
COPY . var/www/app
WORKDIR var/www/app
CMD ["java", "-jar", "app.jar"]

running

docker build -t java-app .

Image built successfully.
When executing

docker run -i -t java-app

I get the following error

Error response from daemon: OCI runtime create failed: container_linux.go:295: starting container process caused "exec: \"java\": executable file not found in $PATH": unknown.

I just followed simple instructions I found on the web. If I understand the error correctly, java isn’t recognised as a command despite Extending the OpenJDK image. Any help?


(Cs02rm0) #2

I think your Dockerfile is fine, seems to work for me.

Might be worth trashing your docker data (preferences->reset->remove all data / restart).


(Fortblox) #3

Silly me, I didn’t realize the openjdk image is just an online installation of java.
I thought it’s an offline java image. My apt wasn’t configured, so nothing worked.
Thanks for the reply.
Close.