Getting a non-zero code: 8 error

Dockerfile

RUN cd /etc/yum.repos.d/
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

ENV JAVA_VERSION_MAJOR=8 \
    JAVA_VERSION_MINOR=171 \
    JAVA_VERSION_BUILD=11 \
    JAVA_URL_HASH=512cd62ec5174c3487ac17c61aaa89e8

RUN yum install -y wget && \
    wget -q --no-cookies --no-check-certificate \
      --header 'Cookie:oraclelicense=accept-securebackup-cookie' \
      "http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_URL_HASH}/jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.rpm"

 RUN   yum install -y jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.rpm && rm -f jre-*.rpm &&  yum clean all

COPY healthId-api/build/distributions/healthId-*.noarch.rpm /tmp/healthId.rpm
RUN yum install -y /tmp/healthId.rpm && rm -f /tmp/healthId.rpm && yum clean all
COPY env/docker_healthid /etc/default/healthid
ENTRYPOINT . /etc/default/healthid && java -jar /opt/healthid/lib/healthId-schema-*.jar && java -Dserver.port=$HEALTH_ID_SERVICE_PORT -DHID_LOG_LEVEL=$HID_LOG_LEVEL -jar  /opt/healthid/lib/healthId-api.war

Error

The command '/bin/sh -c yum install -y wget &&     wget -q --no-cookies --no-check-certificate       --header 'Cookie:oraclelicense=accept-securebackup-cookie'       "http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_URL_HASH}/jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.rpm"' returned a non-zero code: 8

I am a new developer . This is an old project last updated in 2018. Can anyone help me on how to solve this

Are you sure the Java version you try can be distributed for free? If you create an image with a java version, you are distributing it.

That’s why most image maintainers switched to one of the available OpenJDK distributions (see: https://whichjdk.com for a comparison). Personally I favor Eclipse Temurin.

Back to topic: You can always create a container to test each command from your Dockerfile individually. Since you didn’t paste the full Dockerfile, we don’t know what your base image is. But judged by repositories it must be CentOS based.

Run a container using the image used as base image in your Dockerfile: docker run -ti {baseimage}
Then execute the first line in the terminal of the container to see whether it causes the error, then execute the other lines:

yum install -y wget
JAVA_VERSION_MAJOR=8
JAVA_VERSION_MINOR=171
JAVA_VERSION_BUILD=11
JAVA_URL_HASH=512cd62ec5174c3487ac17c61aaa89e8
wget -q --no-cookies --no-check-certificate \
      --header 'Cookie:oraclelicense=accept-securebackup-cookie' \
      "http://download.oracle.com/otn-pub/java/jdk/${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-b${JAVA_VERSION_BUILD}/${JAVA_URL_HASH}/jre-${JAVA_VERSION_MAJOR}u${JAVA_VERSION_MINOR}-linux-x64.rpm

Once you know whether the wget installation is the problem or the wget command, you know what you need to fix. I guess either the version doesn’t exist anymore, the download url changed or Oracle hardened the download url by requiring a special cookie - you need to figure out all these details all by yourself.

But to be honest, I wouldn’t even bother to fix the download, and instead switch to Eclipse Temurin jdk8u362-b09