In my dockerfile I am downloading JDK17, and copying to another directory to build my image. It downloads fine, and when I do an ls, I do see the files. But when I later do an ADD from this location to another location in my container, it does not find the file.
Here is my dockerfile:
FROM oraclelinux:9
ENV JAVA_PKG=java-17-openjdk-17.0.4.0.8-2.el9_0.x86_64.rpm \
JAVA_HOME=/usr/java/default \
HTTP_PROXY=http://myproxyhost:port \
HTTPS_PROXY=http://myproxyhost:port
RUN yum install yum-utils
RUN yumdownloader --destdir target/installer java-17-openjdk -y
RUN ls target/installer
RUN ls target
RUN ls
RUN pwd
ADD target/installer/$JAVA_PKG /usr/java/ -> FAILS
Docker image run output
Step 1/23 : FROM oraclelinux:9
---> fa05a8a60339
Step 2/23 : ENV JAVA_PKG=java-17-openjdk-17.0.4.0.8-2.el9_0.x86_64.rpm JAVA_HOME=/usr/java/default HTTP_PROXY=http://.......
---> Running in bdbf6f67cda5
Removing intermediate container bdbf6f67cda5
---> 9a522a690d6a
Step 3/23 : RUN yum install yum-utils
---> Running in 636d098e505b
Oracle Linux 9 BaseOS Latest (x86_64) 3.5 MB/s | 3.6 MB 00:01
Oracle Linux 9 Application Stream Packages (x86 6.2 MB/s | 8.8 MB 00:01
Last metadata expiration check: 0:00:01 ago on Mon Sep 12 17:32:01 2022.
Package yum-utils-4.0.24-4.0.1.el9_0.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Removing intermediate container 636d098e505b
---> 73abef1e3ed6
Step 4/23 : RUN yumdownloader --destdir target/installer java-17-openjdk -y
---> Running in cee9d1d620db
Last metadata expiration check: 0:00:06 ago on Mon Sep 12 17:32:01 2022.
java-17-openjdk-17.0.4.0.8-2.el9_0.x86_64.rpm 682 kB/s | 244 kB 00:00
Removing intermediate container cee9d1d620db
---> 6ead60b4a32e
Step 5/23 : RUN ls target/installer
---> Running in 6ce3fa03457c
java-17-openjdk-17.0.4.0.8-2.el9_0.x86_64.rpm -----> **File is there**
Removing intermediate container 6ce3fa03457c
---> 68c624f00c20
Step 6/23 : RUN ls target
---> Running in 5e84a200d2d8
installer
Removing intermediate container 5e84a200d2d8
---> b531e9c68a19
Step 7/23 : RUN ls
---> Running in bb11fddb08bc
afs
....
dev
etc
....
opt
proc
root
...
srv
sys
**target** --------> **It is there**
...
Removing intermediate container bb11fddb08bc
---> 7e8da24633f9
Step 8/23 : RUN pwd
---> Running in 3ca7fbfaa1c7
/
Removing intermediate container 3ca7fbfaa1c7
---> bcc07f5b27e4
Step 9/23 : ADD target/installer/$JAVA_PKG /usr/java/
this Step 9 here fails with error:
ADD failed: stat/scratch/docker/tmp/docker-builder814075534/target/installer/java-17-openjdk-17.0.4.0.8-2.el9_0.x86_64.rpm: no such file or directory
Why is it looking in this directory? When I do pwd I am in a "/" directory. ls shows me correct path too. How do I make docker image find my downloaded file?
Appreciate your help thanks