
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 14.1K Views
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/
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 14.1K Views
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 14.1K Views
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 14.1K Views
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 13.6K Views
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 12.7K Views
HI petronela ,
and how to solve the question?
if i can`t extract the gzip manually and the ADD instruction doesn`t work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 12.7K Views
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 12.7K Views
Sent from Mail<> for Windows

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 12.6K Views
but this man page URL : https://www.mankier.com/5/Containerfile says you can use ADD for a recognised zipped tar .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 12.6K Views
The course DO180v4.10 ch05s03 also says the same https://rol.redhat.com/rol/app/courses/do180-4.10/pages/ch05s03

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- 12.7K Views
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.