Hi Guys, a question about COPY command inside Containerfile
is it mandatory that the file I want to copy be in the same folder as the Containerfile/Dockerfile file?
I ask that because in my Containerfile I put the instruction COPY
/home/user/Downloads/file.zip /opt/, however when I run the command podman build, I receive an error message: no such file or directory , however, the file exists in the folder /home/user/Downloads/
Hi RogerioLSantos,
Where is your dockerfile exists?
the folder /home/user/Downloads/file.zip should be into the same context as of dockerfile. Please go through the github issue which was raised for the same.
https://github.com/moby/moby/issues/4592
~Vikas Sharma
Hi RogerioLSantos,
Where is your dockerfile exists?
the folder /home/user/Downloads/file.zip should be into the same context as of dockerfile. Please go through the github issue which was raised for the same.
https://github.com/moby/moby/issues/4592
~Vikas Sharma
Hi vikassharma, my /home/user/Downloads/file.zip is in a different context
I thought that COPY would read any folder in the host.
In this structure works
However, I was trying to use a folder outside of this context, because I thought that COPY has visibility of all folders in the host.
You can't COPY a zip! You need ADD! And add does not work with zip, but with .tar
And you need all of it in the current dir where you execute the build command.
HI petronela ,
and how to solve the question?
if i can`t extract the gzip manually and the ADD instruction doesn`t work?
ADD takes a .tar file. COPY copies files. You either convert the zip into tar before using ADD or you unzip the zip first and use COPY for the unzipped files.
but this man page URL : https://www.mankier.com/5/Containerfile says you can use ADD for a recognised zipped tar .
The course DO180v4.10 ch05s03 also says the same https://rol.redhat.com/rol/app/courses/do180-4.10/pages/ch05s03
Check if you have the `unzip` package installed, normaly you should on a CentOS Linux machine. Otherwise `sudo yum install unzip` to install it. Then `unzip file.zip -d destination_folder` to unzip. At this point I would just use COPY and copy the destination_folder. But you can make it a tar file with `tar -zcvf file.tar.gz /path/to/dir/` - which means you need to have the tar package.
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.