in DockerFile
ockerfile contains instructions
on how the image should be built. Here are some of the most common instructions that you can meet in a Dockerfile:
FROM
is used to specify a base image
for this build. It‘s similar to the builder configuration which we defined in a Packer template, but in this case instead of describing characteristics of a VM, we simply specify a name of a container image used for build. This should be the first instruction in the Dockerfile.ADD
and COPY
are used to copy a file/directory to the container. See the difference between the two.
ADD
allows <src>
to be an URL<src>
parameter of ADD
is an archive in a recognised compression format, it will be unpacked RUN
is used to run a command inside the image. Mostly used for installing packages.ENV
sets an environment variable available within the container.WORKDIR
changes the working directory of the container to a specified path. It basically works like a cd
command on Linux.CMD
sets a default command, which will be executed when a container starts. This should be a command to start your application.
原文:https://www.cnblogs.com/anyu686/p/9084052.html