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


  • login password required to access jupyter notebook running in nvidia-docker container
  • Connecting to mongo container using node getting MongoError
  • publishing message to external Kafka Broker from docker container
  • Kubernetes ACS engine: containers (pods) do not have internet access
  • How to sync the time of a java application running on docker container?
  • Dokku server hosts two sites with TLD's, both domains are landing on only one app
  • 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?)

  • Docker random ports & AWS Elastic Load Balancer
  • Why this is not working to share a data volume using Docker and MongoDB?
  • Docker container with Node and Express on Mac, not showing in browser?
  • Check if image:tag combination already exists on docker hub
  • Upload to s3 from docker container running inside ECS not working
  • docker build is not work
  • 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 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.