Reputation: 2997
I have attempted to create a custom docker image using a provided java8 base image as described here.
The following are the attempts I have made
FROM java
FROM java:latest
FROM java:8
FROM java:8-jdk
When the image was been created I checked the version of Java installed (java -version
), all of which return
java version "1.7.0_101"
OpenJDK Runtime Environment (IcedTea 2.6.6) (7u101-2.6.6-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
This is causing issues because my application is compiled to use Java 1.8. What java image should be used to actually get java8 on the container?
Upvotes: 1
Views: 324
Reputation: 10435
Those should work, and do work for me. Are you sure you're building it and running the new image?
$ echo "FROM java:latest" > Dockerfile
$ docker build -t test .
...
$ docker run --rm test java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-1~bpo8+1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
You can view information about your local images using docker inspect
. If you inspect one of the Java images you should the version of Java in the environment vars:
$ docker inspect java:latest
...
"JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64",
"JAVA_VERSION=8u91",
"JAVA_DEBIAN_VERSION=8u91-b14-1~bpo8+1",
...
If you use docker inspect
to view your image you should see these env vars as well, and can also compare the layers used to the Java image(s) to try and see what's happening.
Upvotes: 1
Reputation: 376
All the images you listed should be running java 8. Make sure you are building the image and running it in a new container after you update the Dockerfile.
echo "FROM java:8" > Dockerfile
docker build -t my-java:latest .
docker run --rm my-java:latest java -version
Upvotes: 0