When you create a project in Visual Studio 2017 with Docker support, the Dockerfile has the following line:
COPY ${source:-obj/Docker/publish} .
What does it mean? Where does the source macro point to? What is the meaning of the dash?
The Copy Command COPY is a dockerfile command that copies files from a local source location to a destination in the Docker container. A Dockerfile is a text file with instructions to set up a Docker container.
The WORKDIR command is used to define the working directory of a Docker container at any given time. The command is specified in the Dockerfile. Any RUN , CMD , ADD , COPY , or ENTRYPOINT command will be executed in the specified working directory.
Each RUN command in a Dockerfile creates a new layer to the Docker image. In general, each layer should try to do one job and the fewer layers in an image the easier it is compress. This is why you see all these '&& 's in the RUN command, so that all the shell commands will take place in a single layer.
That is called variable substitution.
In English, it translates to this:
"Hey Docker, when you build this, COPY
the path you find the in $source
variable in to the current directory in the image (.
). If $source
is empty or absent, just use the default path obj/Docker/publish
"
$source
is an environment variable that is defined before executing docker build
.
Some references:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With