2
votes

Recently I started using Jenkins in a Docker container with Oracle Java 8. When building a project with Gradle I get this error message:

UnsatisfiedLinkError: linux-amd64/libnative-platform.so: libstdc++.so.6: cannot open shared object file: No such file or directory

In Jenkins I selected "Force GRADLE_USER_HOME to use workspace" with no luck at all. The file libnative-platform.so is in the directory expected but gradle won't work. I tried installing Gradle in the container and same result. My last setup is with Gradle Wrapper.

I looked everywhere but I had no luck on my quest. I appreciate if someone can shed a light on this.

3

3 Answers

6
votes

You can make this work by installing the libstdc++ package in Alpine

apk add --no-cache libstdc++
2
votes

libstdc++.so.6: cannot open shared object file

libnative-platform.so of the JRE/JDK is linked against gnu libc but Alpine images are based on musl libc.

The easy solution is to use a glibc based docker image like Debian, if you want to stick with Alpine you might find some clues in this github issue.

2
votes

The problem is that Oracle JDK is linked against GNU C library (glibc) that is not available here.

Alpine Linux doesn’t use glibc as conventional distributions like Debian, Fedora or Gentoo. Instead, it uses musl libc, a lightweight, fast, simple and standards-conform C library (i.e. everything that glibc is not).

The solution is very simple, just install OpenJDK from the Alpine repository (package openjdk8). Don’t worry about compatibility, Oracle JDK 8 is just branded distribution of OpenJDK 8, the code base is nearly identical.

If you insist on Oracle JDK for whatever reason and don’t care about security at all*, then don’t use Alpine Linux, but some conventional distribution…

You can read more in my article JRuby on Alpine Linux on the JRuby wiki.

* Oracle JDK has restricted cryptography by default, because of U.S. policy. It’s distributed with Ask.com adware. And because it’s distributed only as a BLOB, you can’t know what else bad is inside…