Public | Automated Build

Last pushed: a month ago
Short Description
Short description is empty for this repo.
Full Description

Minimal Docker image with Java

Docker image to run Java applications.
This is based off Alpine to keep the size minimal (117 MB).

Consider to use develar/java:8u45-dcevm during development — DCEVM.

Docker compose example to run application from classes:

image: develar/java:8u45
environment:
  _JAVA_OPTIONS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5050 -Xms48m -Xmx64M"
  CLASSPATH: /app/lib/*:/app/classes
volumes:
  - out/production/moduleName:/app/classes:ro
  - lib:/app/lib:ro
command: com.example.ClassName
expose:
 - "80"
ports:
  - "5050:5050"
Docker Pull Command
Owner
develar
Source Repository

Comments (7)
f1yegor
a year ago

I got error
Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError: libstdc++.so.6: cannot open shared object file: No such file or directory during application run.
I found the reason - dependencies use JNA.
com.sun.jna.Native.loadLibrary

Solved with
RUN apk -UUv add libstdc++ && rm -rf /var/cache/apk/*

benjaminbauer
2 years ago

Could you add a u66 tag?

develar
2 years ago

Thanks, added, was not aware of it.

frolvlad
2 years ago

Please, consider adding “Repository Links” to Alpine repo so your image got rebuild when the base image updates.

develar
2 years ago

Thanks frolvlad, I have encountered this issue and applied your fix.

develar
2 years ago

@frolvlad Hi.

it is worthwhile to add this hack inside of our Java images?
Don't think so. I think, any extra changes should be minimized. I am not aware of this issue and Netty/Vertx works for me. So, I prefer to wait first user report :)

frolvlad
2 years ago

This is the greatest image for those who want to package their Java applications!

(However, if you are looking for OracleJDK8 to build applications in Docker check out frolvlad/alpine-oraclejdk8)

Be also aware of a possible issue with Java applications that resolve domain names (i.e. Spark, Hadoop, etc), Alpine Linux doesn't use pam, which means that there is no /etc/nsswitch.conf, but Java relies on /etc/nsswitch.conf to check order of DNS resolving (i.e. /etc/hosts -> DNS-servers lookup). To fix this you can just add /etc/nsswitch.conf yourself:

RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf

Develar, do you think it is worthwhile to add this hack inside of our Java images?