Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADD or COPY a folder in Docker

Tags:

docker

My directory Structure as follows

 Dockerfile downloads 

I want to add downloads to /tmp

 ADD downloads /tmp/  COPY down* /tmp  ADD ./downloads /tmp 

Nothings works. It copies the contents of downloads into tmp. I want to copy the downloads floder. Any idea?

 ADD . tmp/ 

copies Dockerfile also. i dont want to copy Dockerfile into tmp/

like image 891
Gibbs Avatar asked Feb 19 '15 06:02

Gibbs


People also ask

What is difference between ADD and copy in Docker?

COPY is a docker file command that copies files from a local source location to a destination in the Docker container. ADD command is used to copy files/directories into a Docker image. It only has only one assigned function. It can also copy files from a URL.

Does Docker copy create folder?

Docker Dockerfiles COPY InstructionAll new files and directories are created with a UID and GID of 0.

How do I copy a folder from host to container?

Obtain the name or id of the Docker container. Issue the docker cp command and reference the container name or id. The first parameter of the docker copy command is the path to the file inside the container. The second parameter of the docker copy command is the location to save the file on the host.


1 Answers

I believe that you need:

COPY downloads/ /tmp/downloads/ 

That will copy the contents of the downloads directory into a directory called /tmp/downloads/ in the image.

like image 93
James Bielby Avatar answered Sep 19 '22 19:09

James Bielby