Search code examples
javabinarycontainersquarkusglibc

Alternatives to Quarkus base images for native-micro


I am building the binary in a GitHub Action pipeline using mvnw -Pnative. The runner machine uses the latest Ubuntu OS where the glibc version is 2.3x. Whereas, the base Quarkus micro image uses an earlier version of glibc. This results in the following error when the container image is run using docker run.

./application: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ./application)
./application: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./application)

Browsing this site for understanding the library version and distribution is tedious. Therefore, I wanted to know, if you can suggest an alternative micro base image - with "recent" glibc - where, a Quarkus binary can be run?


Solution

  • Honestly I couldn't reproduce this, however my host machine has newer version of glibc and my native container image started successfully. Output of ldd --version
    On the host:

    ldd (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35
    

    On the container image (built by Dockerfile.native)

    ldd (GNU libc) 2.28
    

    Both Dockerfile.native and Dockerfile.native-micro is based on UBI8 which is an Universal Base Image of Red Hat Enterprise Linux. UBI8 is based on RHEL8 and UBI9 is on RHEL9. RHEL9 using recent glibc 2.34.

    Solution #1 - use UBI9-minimal

    Ubi9 minimal base image contains everything (and more), but it is a little bit bigger than micro version.

    In this case just use this base image:

    FROM registry.access.redhat.com/ubi9-minimal:9.2
    
    # ...
    

    Solution #2 create custom micro image

    This guide explains how to create custom base image or extend the existing one.

    This Dockerfile should work:

    # -- Stage ubi
    FROM registry.access.redhat.com/ubi9-minimal:9.2 AS ubi
    # -- Stage scratch
    FROM registry.access.redhat.com/ubi9-micro:9.2 AS scratch
    # -- Final Stage
    FROM scratch
    COPY --from=ubi /usr/lib64/libgcc_s.so.1 /usr/lib64/libgcc_s.so.1
    COPY --from=ubi /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6
    COPY --from=ubi /usr/lib64/libz.so.1 /usr/lib64/libz.so.1
    

    Note: I cloned the quarkus-images repository and changed the arguments to generate this Dockerfile.