I am trying to run a Kafka Streams application in kubernetes. When I launch the pod I get the following exception:
Exception in thread \"streams-pipe-e19c2d9
There are two solutions of this problem:
You may use some other base image with pre-installed snappy-java
lib. For example openjdk:8-jre-slim
works fine for me
And the other solution is to still use openjdk:8-jdk-alpine
image as base one, but then install snappy-java
lib manually:
FROM openjdk:8-jdk-alpine
RUN apk update && apk add --no-cache gcompat
...
In my case, install the missing libc6-compat didn't work. Application still throw java.lang.UnsatisfiedLinkError
.
Then I find in the docker, /lib64/ld-linux-x86-64.so.2
exist and is a link to /lib/libc.musl-x86_64.so.1
, but /lib
only contains ld-musl-x86_64.so.1
, not ld-linux-x86-64.so.2
.
So I add a file named ld-linux-x86-64.so.2
linked to ld-musl-x86_64.so.1
in /lib
dir and solve the problem.
Dockerfile I use:
FROM openjdk:8-jre-alpine
COPY entrypoint.sh /entrypoint.sh
RUN apk update && \
apk add --no-cache libc6-compat && \
ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2 && \
mkdir /app && \
chmod a+x /entrypoint.sh
COPY build/libs/*.jar /app
ENTRYPOINT ["/entrypoint.sh"]
In conclusion:
RUN apk update && apk add --no-cache libc6-compat
ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
I have implemented a docker image with which I run a Spring Boot microservice with a Kafka Strean Topology working perfectly.
Here I share the Dockerfile file.
FROM openjdk:8-jdk-alpine
# Add Maintainer Info
LABEL description="Spring Boot Kafka Stream IoT Processor"
# Args for image
ARG PORT=8080
RUN apk update && apk upgrade && apk add --no-cache gcompat
RUN ln -s /bin/bash /usr/bin
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY resources/wait-for-it.sh wait-for-it.sh
COPY target/iot_processor.jar app.jar
RUN dos2unix wait-for-it.sh
RUN chmod +x wait-for-it.sh
RUN uname -a
RUN pwd
RUN ls -al
EXPOSE ${PORT}
CMD ["sh", "-c", "echo 'waiting for 300 seconds for kafka:9092 to be accessable before
starting application' && ./wait-for-it.sh -t 300 kafka:9092 -- java -jar app.jar"]
Hope it can help someone
It seems strange, but looks like the docker image you use- openjdk:8u151-jdk-alpine3.7 is inconsistent, and some dynamically loaded objects are not included into the package, or you need to run “ldconfig -v” in this image to update map of the shared objects, or, at last, there is /etc/ld.so.conf with the paths to places where OS is looking for .so objects. Please consider using another docker image providing java binary if you do not want to lose time on debugging it. Last but not least, ask for a remedy on alpine forum.
Error message states that *libsnappyjava.so cannot find ld-linux-x86-64.so.2. This is a glibc dynamic loader, while Alpine image doesn't run with glibc. You may try to get it running by installing libc6-compat package in your Dockerfile, e.g.:
RUN apk update && apk add --no-cache libc6-compat