cancel
Showing results for 
Search instead for 
Did you mean: 
RogerioLSantos
Mission Specialist
Mission Specialist
  • 11.8K Views

Podman COPY file

Jump to solution

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/

 

 

Labels (1)
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
vikassharma
Mission Specialist
Mission Specialist
  • 11.8K 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

View solution in original post

9 Replies
vikassharma
Mission Specialist
Mission Specialist
  • 11.8K 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

RogerioLSantos
Mission Specialist
Mission Specialist
  • 11.8K 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

Captura de tela de 2022-01-25 10-38-11.png

 

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.

 

 

 

 

 

 

 

 

 

Petronela
Mission Specialist
Mission Specialist
  • 11.2K 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.

Mmujahed
Mission Specialist
Mission Specialist
  • 10.4K Views

HI petronela ,

and how to solve the question?

if i can`t extract the gzip manually and the ADD instruction doesn`t work?

 

Petronela
Mission Specialist
Mission Specialist
  • 10.3K 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. 

Mmujahed
Mission Specialist
Mission Specialist
  • 10.3K Views
How to convert it to local?

Sent from Mail<> for Windows
Chetan_Tiwary_
Community Manager
Community Manager
  • 10.3K Views

but this man page URL : https://www.mankier.com/5/Containerfile  says you can use ADD for a recognised zipped tar . 

 

chetan_tiwary_0-1663068145690.png

 

0 Kudos
Chetan_Tiwary_
Community Manager
Community Manager
  • 10.3K Views

The course DO180v4.10  ch05s03  also says the same   https://rol.redhat.com/rol/app/courses/do180-4.10/pages/ch05s03 

 

chetan_tiwary_1-1663068210821.png

 

0 Kudos
Petronela
Mission Specialist
Mission Specialist
  • 10.3K 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.

Join the discussion
You must log in to join this conversation.