Sasha Shpota
Sasha Shpota

Reputation: 10280

Run Java 12 application in Docker

I took a look at OpenJDK Docker repository and found no JRE image for Java 12. There is one for Java 11 (openjdk:11.0.2-jre), but for 12 there are only JDK images.

Q: How to use OpenJDK JRE 12 to run an application in Docker without using a full JDK image?

Upvotes: 5

Views: 3486

Answers (2)

David Ramos
David Ramos

Reputation: 77

I was able to successfully deploy the following dockerfile for a spring boot application, with gradle and java 12:

FROM adoptopenjdk/openjdk12-openj9 AS TEMP_BUILD_IMAGE
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY build.gradle settings.gradle gradlew $APP_HOME
COPY gradle $APP_HOME/gradle
RUN chmod +x ./gradlew
RUN ./gradlew build || return 0
COPY . .
RUN chmod +x ./gradlew
RUN ./gradlew build -x test

FROM adoptopenjdk/openjdk12-openj9
ENV ARTIFACT_NAME=example_app-1.0.jar
ENV APP_HOME=/usr/app/
WORKDIR $APP_HOME
COPY --from=TEMP_BUILD_IMAGE $APP_HOME/build/libs/$ARTIFACT_NAME .
EXPOSE 8080
#CMD ["java","-jar",$ARTIFACT_NAME]
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=container","-jar","./example_app-1.0.jar"]

Upvotes: 0

Gonzalo Matheu
Gonzalo Matheu

Reputation: 10064

AdoptOpenJDK is already providing Java 12 JRE docker images (adoptopenjdk/openjdk12:jre-12.33)

AdoptOpenJDK is a Java community based effort and from its about page:

AdoptOpenJDK.net started in 2017 following years of discussions about the general lack of an open and reproducible build & test system for OpenJDK source across multiple platforms.

And one key point of their mission is:

Provide a reliable source of OpenJDK binaries for all platforms, for the long term future!

There is no pull request for 12 jre on OpenJdk official image repository yet (which is maintained by Docker community.

Upvotes: 4

Related Questions