Update on 31.3.2015 Updated the Java version to 1.8.0_40.
Installing Java 8 on BusyBox
After spending [some time]({% post_url 2014-11-06-Microservices-in-Microcontainers-with-Docker %}) with [microcontainers]({% post_url 2014-12-04-java-and-nodejs-in-microcontainers-with-docker %}) I got interested in trying to make the smallest feasible self contained container that includes a working recent Java 8 JRE. I’m fond of using BusyBox (especially progrium/busybox) as the base image as it contains most of the libraries needed to be usable while still being under 5 MB in size.
I decided to call containers built this way [minicontainers as opposed to microcontainers]({% post_url 2014-12-31-fat-containers-microcontainers-and-minicontainers %}) that share the runtimes using volume containers. Volume container support is still pretty non-existent in orchestrators so self-contained containers are more portable between hosts.
Downloading the installation packets
As the Oracle’s Java download page requires the user to accept things by selecting radio boxes, getting the file to download automatically isn’t exactly trivial. There was an excellent answer on stackoverflow for this exact issue which described the command to use:
| |
One problem with using wget in BusyBox is that the wget that comes with the progrium/busybox image doesn’t understand https or ssl in general. Luckily there is a package for wget-ssl that can be installed directly with opkg manager that does support https.
Libpthread hack
As installing wget-ssl updates libpthreads to such a version that Java executable breaks, the following is needed to get Java to run again:
| |
Dockerfile
| |
Building
The container can be built by running
| |
The resulting image is 178.7MB in size.
Testing
After building, the image can be run with
| |