Docker image with opencv and java


I’ve implemented a java (Springboot) application that uses opencv (openpnp). I tried many different things to put that in a docker image without success.

That generates JVM issues:

FROM openjdk:17-alpine

RUN apk update && \
    apk upgrade && \
    apk add --no-cache tesseract-ocr opencv gcompat

COPY myapp-1.0.0.jar myapp-1.0.0.jar

ENTRYPOINT ["java","-jar","/myapp-1.0.0.jar"]

i tried to use that image or build it like that:

Is there anybody that achieved to use a similar setup? If possible with java 17 and the last opencv version.

Many thanks!!

if there are any errors, please show !

That’s the error for the first docker image:

# A fatal error has been detected by the Java Runtime Environment:
#  SIGSEGV (0xb) at pc=0x00000000001e1766, pid=1, tid=124
# JRE version: OpenJDK Runtime Environment (17.0+14) (build 17-ea+14)
# Java VM: OpenJDK 64-Bit Server VM (17-ea+14, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  0x00000000001e1766
# Core dump will be written. Default location: Core dumps may be processed with "/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e %P %I %h" (or dumping to //core.1)
# An error report file with more information is saved as:
# //hs_err_pid1.log
[thread 125 also had an error][thread 127 also had an error][thread 128 also had an error]

there should be something in hs_err_pid1.log

your question here:

looks like you actually run some code, so it must have built, correct ?

My java code and docker image build correctly, the application starts, other endpoints work correctly. But as soon as it starts to use opencv, it fails

The content of the error file is here

yea, seen your log. unfortunately no trace of opencv calls there ;[