This project create docker images for OpenJDK 1.8.0_40-b25
.
There is an image for each "compact profile" (see JEP 161 ) : compact1
, compact2
, compact3
and jre
(=full SE)
These JREs are very small because they're made for embedded system.
There are a tagged image for each "compact profile" :
8-jre
,latest
(openjdk/Dockerfile)8-compact3
(openjdk/Dockerfile)8-compact2
(openjdk/Dockerfile)8-compact1
(openjdk/Dockerfile)
tl;dr : Busybox + libc 64bit + libc 32 bits + Embedded JRE = Small Java Container
All image are based on Busybox with 32 bits (and 64 bits) libs (see docker-busybox-jvm and docker-busybox-lib32 ).
The overhead on top of a JRE is around 8 MB.
JVM aren't statically linked so you can still navigate inside container or use some shell scripting.
JRE are always installed in /usr/lib/jvm
and link to /usr/lib/jvm/jre
.
Sample :
/ # ls -l /usr/lib/jvm/
total 4
drwxr-xr-x 4 root root 4096 Jul 15 23:03 java-se-8u40-ri-compact1
lrwxrwxrwx 1 root root 34 Jul 15 23:03 jre -> /usr/lib/jvm/java-se-8u40-ri-compact1
The biggest advantage of these image are their size : only 47 MB for a "compact" edition and 115 MB for a full SE JRE.
It's 6 or 12 times smaller than the official java image (cause it's headfull and based on a full Debian) !
Here is a list of some java image.
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ofayau/j2me latest f56c31b1cc20 26 hours ago 21.73 MB
ofayau/ejre 8-compact1 824a6f1a0ade 4 minutes ago 39.31 MB
ofayau/ejre 8-compact2 9da39771057a 4 minutes ago 44.85 MB
ofayau/ejre 8-compact3 a9fbe6b90034 4 minutes ago 48.79 MB
ofayau/ejre 8-jre d5ed29a4bf44 4 minutes ago 80.66 MB
ofayau/openjdk 8-compact1 f258bd30ec46 5 days ago 47.08 MB
ofayau/openjdk 8-compact2 dc125eeac09b 5 days ago 59.82 MB
ofayau/openjdk 8-compact3 b10fc16f53ea 5 days ago 66.38 MB
ofayau/openjdk 8-jre fded935a77ed 5 days ago 115.1 MB
frolvlad/alpine-oraclejdk8 latest 8e87306ea37d 7 weeks ago 170.4 MB
jeanblanchard/busybox-java 8 f9b532dbdd9f 3 months ago 162 MB
java 8-jre b0f21df5333b 5 months ago 478.7 MB
-
truncated JRE : "compact profiles" doesn't contain every java package. Only
8-jre
is considered as full SE (but still headless). -
32 bits only : you can't run 64 bits code.
-
JRE, not JDK : hence there is no compiler (
javac
) included, only runtime executor (java
). You have to compile somewhere else (i.e. a standard jdk 8).
-
Busybox : see license information.
-
Debian libc-i386 : see licence of debian package.
-
Oracle and Java : see OTN licence.
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Download or update tagged images :
docker pull ofayau/openjdk:8-compact1
docker pull ofayau/openjdk:8-compact2
docker pull ofayau/openjdk:8-compact3
docker pull ofayau/openjdk:8-jre
docker pull ofayau/openjdk:latest
Showing java version of every image :
# docker run --rm -it ofayau/openjdk:8-compact1
openjdk version "1.8.0_40"
OpenJDK Runtime Environment (build 1.8.0_40-b25, profile compact1)
OpenJDK Server VM (build 25.40-b25, mixed mode)
# docker run --rm -it ofayau/openjdk:8-compact2
openjdk version "1.8.0_40"
OpenJDK Runtime Environment (build 1.8.0_40-b25, profile compact2)
OpenJDK Server VM (build 25.40-b25, mixed mode)
# docker run --rm -it ofayau/openjdk:8-compact3
openjdk version "1.8.0_40"
OpenJDK Runtime Environment (build 1.8.0_40-b25, profile compact3)
OpenJDK Server VM (build 25.40-b25, mixed mode)
# docker run --rm -it ofayau/openjdk:8-jre
openjdk version "1.8.0_40"
OpenJDK Runtime Environment (build 1.8.0_40-b25)
OpenJDK Server VM (build 25.40-b25, mixed mode)
Simple runs
# Run a fat jar from current dir with full JRE
docker run --rm -v "$PWD":/tmp/myapp -w /tmp/myapp ofayau/openjdk java -jar myFatJar.jar
Compile and run for compact1
# Compile with jdk 8 (outside of this container)
javac -profile compact1 HelloWorld.java
# Run a "HelloWorld" class from current dir
docker run --rm -v "$PWD":/tmp/myapp -w /tmp/myapp ofayau/openjdk:8-compact1 java HelloWorld.class