Minimal Docker image with Java
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"
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.
RUN apk -UUv add libstdc++ && rm -rf /var/cache/apk/*
Could you add a u66 tag?
Thanks, added, was not aware of it.
Please, consider adding “Repository Links” to Alpine repo so your image got rebuild when the base image updates.
Thanks frolvlad, I have encountered this issue and applied your fix.
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 :)
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
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?