Introducing our new CEO Don Johnson - Read More

bellsoft/liberica-openjre-alpine

Verified Publisher

By BellSoft

Updated 17 days ago

Liberica is a 100% open-source Java implementation by BellSoft

Image
Languages & Frameworks
Internet of Things
23

1M+

bellsoft/liberica-openjre-alpine

What is Liberica JDK?

Liberica JDK is free and 100% open-source Progressive Java Runtime for modern Java deployments. It is developed and supported by BellSoft, a major OpenJDK contributor. Application development with Liberica JDK is

  • Flexible. Liberica JDK supports the widest range of present-day architectures and operating systems, which makes it a unified Java runtime for desktop, server, cloud, and embedded use cases.
  • Cost- and time-efficient. BellSoft produces the smallest containers in the world based on Liberica Lite and Alpine Linux, which enable companies to minimize deployment time and reduce cloud expenses.
  • Secure. Liberica JDK is TCK-verified for Java SE specifications and thoroughly tested for exposures before every release. The CPU release cycle helps to deliver timely security patches and bug fixes to keep the runtime secure and performant at all times.

Liberica JDK is recommended and used by Spring as the end-to-end solution for Spring Native applications. BellSoft serves millions of developers and companies from various industries across the globe. For more information, visit www.bell-sw.com.

How to choose an optimal Java image?

We compiled an interactive scheme that will help you decide which BellSoft’s image is perfect for your project. How to choose an optimal java image

What’s in this image?

This repository contains Alpine glibc Docker images of Liberica JRE. Alpine Linux is a lightweight Linux distribution with the base image of ~5MB, which allows minimizing the size of a container. The original Alpine is based on musl, but if you are using a glibc-based distribution and unwilling to migrate to another libc, we added Liberica JRE images for Alpine glibc. We have been shipping images of Liberica JDK with Alpine musl since JDK 11. BellSoft’s engineers have upstreamed the support of this OS into JDK 16 and beyond as part of the Portola Project, and now we produce the smallest containers on the market that are only 42.72 MB, which are compatible with all Java applications. Microcontainers with Alpine Linux and Liberica JDK are perfect for building Java microservices:

  • They are 5—7 times smaller than traditional images (based on CentOS or Debian, for example), and thus help to reduce cloud resource consumption dramatically
  • They accelerate the deployment times
  • Fixes and enhancements are introduced continuously and promptly, keeping the containers secure and performant at all times

Liberica JDK images for Alpine are available for following architectures:

  • x86_64 (aka amd64)
  • aarch64 (aka ARM64)
  • armhf (for devices like Raspberry Pi 2/3)

The tags point at the Java version (right after the OS name) and supported architecture. Image name structure: X-Y, where X is the Java version and Y is the architecture type. If the architecture type is not included into the name, then the build supports AMD64 and ARM64 by default. The ‘latest’ tag points to the latest version of an image. Images with '-cds' in tag contain CDS (Class Data Sharing) archive. For instance, bellsoft/liberica-openjre-alpine:8u352-8-x86_64 is an image with Liberica JDK version 8u352 for Alpine glibc running on x86_64.

Alpaquita Linux is a free and advanced replacement for Alpine to use in containers with Liberica JDK.

Alpaquita is a lightweight Linux distribution that integrates all the main features of Alpine plus multiple enhancements and enterprise support.

Like Alpine, Alpaquita is a small and performant Linux distribution, but in addition to that, it

  • supports both musl and glibc,
  • provides an optimized version of musl,
  • is more secure thanks to the kernel hardening, Secure Boot support, and other features,
  • contains multiple performance enhancements.

The most important Alpaquita’s feature for the enterprise development is the support from the BellSoft team. Containers with Alpaquita and Liberica JDK are a unified solution with tested and perfectly compatible components that receive support and regular updates from a single vendor. Our clients obtain fixes on demand, which are implemented in the next release and become available for everyone. We provide Long-Term Support and a software bill of materials both for Liberica JDK and Alpaquita Linux.

As such, containers with Alpaquita are a free and better alternative to Alpine-based solutions.

You can find them at https://hub.docker.com/r/bellsoft/liberica-runtime-container

Tags

Usage

For example, you can run a Liberica OpenJRE 8u272 container with the following command:

docker run -it --rm bellsoft/liberica-openjre-alpine:8u272 java -version

To run some application you can create Dockerfile, based on bellsoft/liberica-openjre-alpine image or mount volume with your code/applicaiton, for example:

docker run -it --rm -v /home/user/project/:/data bellsoft/liberica-openjre-alpine:8u272 java -jar /data/MyApp.jar

Off-screen rendering

Containerized deployments sometimes do some off-screen rendering, such as when preparing documents, forms, and images. When performing off-screen rendering, the JDK requires OS fonts and fontconfig libraries to be present. In case when you don't have these libraries or fonts you will encounter the exception, similar to one below:

Exception in thread "main" java.lang.InternalError: java.lang.reflect.InvocationTargetException
	at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:86)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
	at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
	at java.desktop/sun.font.SunFontManager.getInstance(SunFontManager.java:247)
	at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:261)
	at java.desktop/sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1243)
...
	at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:192)
	at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
Caused by: java.lang.NullPointerException
	at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262)
	at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225)
	at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:107)
	at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:719)
	at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:362)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
	at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:307)
	at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
	at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
	... 28 more

On Alpine Linux, these libraries are provided by fontconfig and ttf-dejavu packages, and can be installed by running the following command:

apk add fontconfig ttf-dejavu

The Liberica JDK Dockerfile can be built with these libraries by specifying OPT_PKGS build argument:

docker build -t bellsoft/liberica-openjre-alpine:8u242 \
  --build-arg LIBERICA_RELEASE_TAG=8u272+10 \
  --build-arg LIBERICA_VERSION=8u272 \
  --build-arg LIBERICA_BUILD=7 \
  --build-arg LIBERICA_VARIANT=jre \
  --build-arg LIBERICA_ROOT=/usr/lib/jvm/jre-8u272-bellsoft-x86_64 \
  --build-arg OPT_PKGS="fontconfig ttf-dejavu"

Docker Pull Command

docker pull bellsoft/liberica-openjre-alpine