Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy all project. Docker file command

Just started to work with docker and I can't figure out how copy all project files into docker image?

Let's say we have structure:

----my-app

-------------------api

-------------------config

-------------------lib

-------------------public

-------------------Dockerfile

-------------------index.html

So, how can I copy all these folders and files into docker container? What command in Dockerfile should I use?

Super easy solution is to use multiple time COPY command. But I believe, that it's wrong way

like image 925
TK-95 Avatar asked Feb 01 '26 14:02

TK-95


2 Answers

put your files in a repository, and do a git clone or hg clone of course you will need to install git or mercurial before, and remove them after, see as an example

hub.docker.com/r/k3ck3c/simh_alpine

like image 156
user2915097 Avatar answered Feb 03 '26 09:02

user2915097


As I seen in Dockerfile documentation on COPY says:

The COPY instruction copies new files or directories from and adds them to the filesystem of the container at the path .

Therefore you can copy a whole directory.

like image 25
Dimitrios Desyllas Avatar answered Feb 03 '26 10:02

Dimitrios Desyllas