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

https://docs.docker.com/examples/nodejs_web_app/

  • Docker MEAN stack which FROM to use?
  • Issue with docker Inter container communication on the isolated bridge
  • Dockerfile RUN command returning “No such file or directory”
  • Boot2Docker/Fig mounted volume not refreshing
  • Docker exits CMD on start
  • Docker : find sendmail in other container
  • https://github.com/enokd/docker-node-hello/

    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?)

  • the docker's host machine cannot connect internet
  • Using a Docker image to build and deploy as part of a build matrix
  • How to run 2 wordpress blogs using docker on ec2
  • Follow docker port mapping inside container
  • Git Repository is not visible on docker hub for automatic build
  • Docker - issue command from one linked container to another
  • 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.

    edit

    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 index.js and 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…

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.