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
  _JAVA_OPTIONS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5050 -Xms48m -Xmx64M"
  CLASSPATH: /app/lib/*:/app/classes
  - out/production/moduleName:/app/classes:ro
  - lib:/app/lib:ro
command: com.example.ClassName
 - "80"
  - "5050:5050"
Docker Pull Command
Source Repository

Comments (7)
a year ago

I got error
Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError: cannot open shared object file: No such file or directory during application run.
I found the reason - dependencies use JNA.

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

2 years ago

Could you add a u66 tag?

2 years ago

Thanks, added, was not aware of it.

2 years ago

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

2 years ago

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

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 :)

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?