My dockerfile looks like this. But when i build, i get the following error. If i do this on my docker image and do wget with the bash on it, it strangely works.
docker build -t mydocker:latest
FROM amazonlinux:2022
RUN mkdir -p /APP
WORKDIR APP
RUN yum update -y
RUN yum install wget -y
RUN mkdir -p /usr/share/man/man1/
RUN wget https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz
RUN yum install tar -y
RUN yum install gzip -y
COPY openjdk-17_linux-x64_bin.tar.gz /APP
RUN tar xvf openjdk-17_linux-x64_bin.tar.gz
Step 11/11 : RUN tar xvf openjdk-17_linux-x64_bin.tar.gz
---> Running in 83a94400e4b7
jdk-17/bin/jar
jdk-17/bin/jarsigner
jdk-17/bin/java
jdk-17/bin/javac
jdk-17/bin/javadoc
jdk-17/bin/javap
jdk-17/bin/jcmd
jdk-17/bin/jconsole
jdk-17/bin/jdb
jdk-17/bin/jdeprscan
jdk-17/bin/jdeps
jdk-17/bin/jfr
jdk-17/bin/jhsdb
jdk-17/bin/jimage
jdk-17/bin/jinfo
jdk-17/bin/jlink
jdk-17/bin/jmap
jdk-17/bin/jmod
jdk-17/bin/jpackage
jdk-17/bin/jps
jdk-17/bin/jrunscript
jdk-17/bin/jshell
jdk-17/bin/jstack
jdk-17/bin/jstat
jdk-17/bin/jstatd
jdk-17/bin/keytool
jdk-17/bin/rmiregistry
jdk-17/bin/serialver
jdk-17/conf/logging.properties
jdk-17/conf/management/jmxremote.access
jdk-17/conf/management/jmxremote.password.template
jdk-17/conf/management/management.properties
jdk-17/conf/net.properties
jdk-17/conf/sdp/sdp.conf.template
jdk-17/conf/security/java.policy
jdk-17/conf/security/java.security
jdk-17/conf/security/policy/README.txt
jdk-17/conf/security/policy/limited/default_US_export.policy
jdk-17/conf/security/policy/limited/default_local.policy
jdk-17/conf/security/policy/limited/exempt_local.policy
jdk-17/conf/security/policy/unlimited/default_US_export.policy
jdk-17/conf/security/policy/unlimited/default_local.policy
jdk-17/conf/sound.properties
jdk-17/include/classfile_constants.h
jdk-17/include/jawt.h
jdk-17/include/jdwpTransport.h
jdk-17/include/jni.h
jdk-17/include/jvmti.h
jdk-17/include/jvmticmlr.h
jdk-17/include/linux/jawt_md.h
jdk-17/include/linux/jni_md.h
jdk-17/jmods/java.base.jmod
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
CodePudding user response:
I changed your Dockerfile
to be:
FROM amazonlinux:2022
RUN mkdir -p /APP
WORKDIR APP
RUN yum update -y
RUN yum install wget -y
RUN mkdir -p /usr/share/man/man1/
RUN wget https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz
RUN yum install tar -y
RUN yum install gzip -y
RUN tar xvf openjdk-17_linux-x64_bin.tar.gz -C /APP
and was able to create the container just fine. If I used your Dockerfile
I got:
Step 10/11 : COPY openjdk-17_linux-x64_bin.tar.gz /APP
COPY failed: file not found in build context or excluded by .dockerignore: stat openjdk-17_linux-x64_bin.tar.gz: file does not exist
because COPY
copies from the host file system, not the Docker file system. Perhaps your local copy of openjdk-17_linux-x64_bin.tar.gz
is truncated.
Alternately, since you're using the Amazon Linux docker image you could use Amazon's Java (Corretto) with something like:
FROM amazonlinux:2022
RUN mkdir -p /APP
WORKDIR APP
RUN yum update -y
RUN yum install wget -y
RUN mkdir -p /usr/share/man/man1/
RUN yum install tar -y
RUN yum install gzip -y
RUN yum install java-11-amazon-corretto-headless -y
Assuming you want the "headless" version.
My docker version is "20.10.18".