dockerrhelredhat-openjdk

Docker: Openjdk:14 RHEL based imaged, cannot install yum/wget/netstat


In my dockerfile, I need a maven builder (3.6 at least) working on a OpenJDK (J14 is required).

FROM maven:3.6.3-openjdk-14 as builder

The problem is simple: I need netstat command because it is used in several scripts. The OpenJDK official image is RHEL based, so it comes without any of this package installed. I tried to download it or yum via wget command but, as you can guess, it is not installed. I feel trapped because it seems like you cannot you can't install any package on it.


Solution

  • That image is actually based on Oracle

    $ podman run -it maven:3.6.3-openjdk-14 /bin/bash -c 'cat /etc/os-release'
    NAME="Oracle Linux Server"
    VERSION="8.2"
    ID="ol"
    ID_LIKE="fedora"
    VARIANT="Server"
    VARIANT_ID="server"
    VERSION_ID="8.2"
    PLATFORM_ID="platform:el8"
    PRETTY_NAME="Oracle Linux Server 8.2"
    ANSI_COLOR="0;31"
    CPE_NAME="cpe:/o:oracle:linux:8:2:server"
    HOME_URL="https://linux.oracle.com/"
    BUG_REPORT_URL="https://bugzilla.oracle.com/"
    
    ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8"
    ORACLE_BUGZILLA_PRODUCT_VERSION=8.2
    ORACLE_SUPPORT_PRODUCT="Oracle Linux"
    ORACLE_SUPPORT_PRODUCT_VERSION=8.2
    

    And this is actually a "slim" variant where dnf or yum aren't installed, but microdnf is. Try using that, instead:

    RUN microdnf install /usr/bin/netstat
    

    Or

    RUN microdnf install net-tools