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/

  • Have to set up eval $(dinghy env) everytime. Cannot connect to the Docker daemon. Is the docker daemon running on this host?
  • Etcd cluster setup failure
  • How to copy files from Windows host to Docker container
  • Pacman: How to choose default choice when it asks to replace a package?
  • Start an existing docker ubuntu container [duplicate]
  • Running docker as non-root user OR running jenkins on tomcat as root user
  • 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?)

  • wso2CEP on docker - supports JMS (activemq) and other clients
  • APK is not installing in docker emulator
  • How does Docker for Windows run Linux containers?
  • App running on docker consuming page cache of host machine.Is that anti-pattern ?
  • Docker container DHCP like bridged VirtualBox
  • What's the idiomatic way to share files between docker containers?
  • 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.