Running the Tanuki Java Service Wrapper in Alpine Linux

By | February 11, 2016

Alpine Linux is a lightweight Linux distribution which, as far as I am concerned, makes it especially suitable to use in Docker images.
The Java Service Wrapper from Tanuki enables Java applications to run as services and is also useful just to launch a Java application, since it will restart it under certain error conditions.

Unfortunately, the Service Wrapper is built against the GNU C library, or glibc for short. Alpine Linux instead uses musl libc, a considerably smaller alternative to glibc. If you try to run the Service Wrapper in Alpine Linux you will get an error message similar to this:

wrapper-linux-x86-64: not found

The good news is that a kind soul has created glibc packages for Alpine Linux. To install the libraries that enable us to run the Java Service Wrapper in Alpine Linux, use the following commands:

# Install glibc library required by the Java Wrapper.
    wget "https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk" \
         "https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-bin-2.21-r2.apk" && \
    apk add --allow-untrusted glibc-2.21-r2.apk glibc-bin-2.21-r2.apk && \
    /usr/glibc/usr/bin/ldconfig /lib /usr/glibc/usr/lib && \
    rm *.apk

For those looking for a Docker image with Alpine Linux, a Java JRE or JDK and the glibc library, I can recommend the anapsix/alpine-java Docker image.

Happy coding!

 

Leave a Reply

Your email address will not be published. Required fields are marked *