4

I am trying to dockerize 4 services and I have a problem with one of the services. Particularly, this service is implemented is spring boot service and uses google vision API. When building the images and starting the containers everything works fine, until it gets to the part where the google vision API code is used. I then have the following runtime errors when running the containers:

netty-tcnative unavailable (this may be normal)
java.lang.IllegalArgumentException: Failed to load any of the given libraries: [netty_tcnative_linux_x86_64, netty_tcnative_linux_x86_64_fedora, netty_tcnative_x86_64, netty_tcnative]
at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:104) ~[grpc-netty-shaded-1.18.0.jar!/:1.18.0]
at io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:526) ~[grpc-netty-shaded-1.18.0.jar!/:1.18.0]
at io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:93) ~[grpc-netty-shaded-1.18.0.jar!/:1.18.0]
at io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:244) [grpc-netty-shaded-1.18.0.jar!/:1.18.0]
at io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:171) [grpc-netty-shaded-1.18.0.jar!/:1.18.0]
at io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:120) [grpc-netty-shaded-1.18.0.jar!/:1.18.0]
at io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder.buildTransportFactory(NettyChannelBuilder.java:385) [grpc-netty-shaded-1.18.0.jar!/:1.18.0]
at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:435) [grpc-core-1.18.0.jar!/:1.18.0]
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:223) [gax-grpc-1.42.0.jar!/:1.42.0]
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:164) [gax-grpc-1.42.0.jar!/:1.42.0]
at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:156) [gax-grpc-1.42.0.jar!/:1.42.0]
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:157) [gax-1.42.0.jar!/:1.42.0]
at com.google.cloud.vision.v1.stub.GrpcImageAnnotatorStub.create(GrpcImageAnnotatorStub.java:84) [google-cloud-vision-1.66.0.jar!/:1.66.0]
at com.google.cloud.vision.v1.stub.ImageAnnotatorStubSettings.createStub(ImageAnnotatorStubSettings.java:120) [google-cloud-vision-1.66.0.jar!/:1.66.0]
at com.google.cloud.vision.v1.ImageAnnotatorClient.<init>(ImageAnnotatorClient.java:136) [google-cloud-vision-1.66.0.jar!/:na]
at com.google.cloud.vision.v1.ImageAnnotatorClient.create(ImageAnnotatorClient.java:117) [google-cloud-vision-1.66.0.jar!/:na]
at com.google.cloud.vision.v1.ImageAnnotatorClient.create(ImageAnnotatorClient.java:108) [google-cloud-vision-1.66.0.jar!/:na]

Complete log file of the error can be found in this link: Complete Log File.

Here are my docker-compose.yml file and the Dockerfile of the service causing problem:

DockerFile

FROM maven:3.6.0-jdk-8-alpine
WORKDIR /app/back
COPY src src
COPY pom.xml .
RUN mvn clean package

FROM openjdk:8-jdk-alpine
RUN apk add --no-cache curl
WORKDIR /app/back

COPY --from=0 /app/back/target/imagescanner*.jar ./imagescanner.jar
COPY --from=0 /app/back/target/classes/API-Key.json .
ENV GOOGLE_APPLICATION_CREDENTIALS ./API-Key.json
EXPOSE 8088

ENTRYPOINT ["java", "-jar", "./imagescanner.jar"]

docker-compose.yml

version: '3'

services:
   front:
     container_name: demoLab_front
     build: ./front
     image: demolab/front:latest
     expose:
       - "3000"
     ports:
       - "8087:3000"
     restart: always
   back:
     container_name: demoLab_backGCV
     build: ./backGCV
     image: demolab/backgcv:latest
     depends_on:
       - lab
     ports:
       - "8088:8088"
     restart: always
   lab:
     container_name: demoLab_labGCV
     build: ./lab
     image: demolab/labgcv:latest
     expose:
       - "8089"
     ports:
       - "8089:8089"
     restart: always
   sift:
     container_name: demoLab_labSIFT
     build: ./detect-label-service
     image: demolab/labsift:latest
     expose:
       - "5000"
     ports:
       - "5000:5000"
     restart: always

EDIT

After some googling I found out that: GRPC Java examples are not working on Alpine Linux since required libnetty-tcnative-boringssl-static depends on glibc. Alpine is using musl libc and application startup will fail with message similar to mine. I found this project that try to build the right images but it seems broken for a lot of pepole (the build didn't work for my case)

Mr. D
  • 657
  • 1
  • 8
  • 21
  • I can see in logs there is a missing dependency file "libcrypt.so.1". Suppressed: java.lang.UnsatisfiedLinkError: /tmp/libio_grpc_netty_shaded_netty_tcnative_linux_x86_641095585491871975468.so: Error loading shared library libcrypt.so.1: No such file or directory (needed by /tmp/libio_grpc_netty_shaded_netty_tcnative_linux_x86_641095585491871975468.so) – Rohit Jindal Apr 16 '19 at 12:37
  • 1
    You are right I just edit the question which answers why it is missing – Mr. D Apr 16 '19 at 13:02

2 Answers2

5

Problem solved by replacing this line of the Dockerfile:

FROM openjdk:8-jdk-alpine

with this line:

FROM koosiedemoer/netty-tcnative-alpine
Mr. D
  • 657
  • 1
  • 8
  • 21
1

The problem: Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative in java.library.path On alpine container.

There is a simple workaround:

apk add libressl
apk add openssl
ln -s /lib/ld-musl-x86_64.so.1 /lib/libcrypt.so.1
Luciano Ribas
  • 309
  • 2
  • 4