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


  • docker --insecure-registry flag not working as expected
  • meet Call to undefined function Xinax\LaravelGettext\bindtextdomain() error in LaravelProject
  • Docker container with licensed software
  • How to grant privileges on mysql from Dockerfile?
  • Running Gitlab Docker
  • How could I execute 'apt-get install' on docker ubuntu contain?
  • 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?)

  • Mounting (possibly corrupt) docker partitions with devicemapper
  • Fig apparently not using volume_from on mysql service
  • How to connect my NodeJS with my Angular (in Nginx)
  • docker 1.9.0 network support in mesos
  • How to link multiple Docker containers and encapsulate the result?
  • golang:sshfs -o reconnect fails when used inside docker container with “reading directory .: Input/output error”
  • 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.