what is “COPY . /src”for when building a image
I’m new to docker,I’m reading the docker’s documentation.
there is a simple example in it
I’m confused about this”COPY . /src”in the Dockerfile.
In this example, “.” represent the directory where the Dockerfile is in(the current dir,in my computer,it is /home/pete),So why do I have to copy all the files in /home/pete to /src?(does this what the instruction mean?)
2 Solutions collect form web for “what is “COPY . /src”for when building a image”
COPY copies files from the host directory (where host is a system running the docker) to the docker container. You might well want to start with Docker’s tutorial – easy to read and will save you some time.
Technically in the examples you show you don’t need to copy all of the contents of the current directory to the container – you would be just fine with just
package.json, but the authors copy
. for the simplicity sake.
Usually, when you build a new image, you create a specific directory, where you put all what you will need for this specific image, your Dockerfile, the files you want to add…
If you have 20 Tera of data in /home/pete, your build will be very long, with no reason
Edit: you will see “uploading context”, which means docker reads and compresses all files in /home/pete and in all you subdirectories…