Dockerfiles are files used to programatically build Docker images. They allow you to quickly and reproducibly create a Docker image, and so are useful for collaborating.
Dockerfiles contain instructions for building a Docker image. Each instruction is written on one row, and is given in the form <INSTRUCTION><argument(s)>
. Dockerfiles are used to build Docker images using the docker build
command.
Dockerfiles are of the form:
# This is a comment
INSTRUCTION arguments
#
FROM
to specify the base imageWhen building a Dockerfile, the Docker client will send a "build context" to the Docker daemon. The build context includes all files and folder in the same directory as the Dockerfile. COPY
and ADD
operations can only use files from this context.
Some Docker file may start with:
# escape=`
This is used to instruct the Docker parser to use `
as an escape character instead of \
. This is mostly useful for Windows Docker files.