EXPOSE instruction informs Docker that the container will listen on the specified network ports at runtime. It won’t actually publish the port. It documents what ports are intended to be published. To actually publish the port at runtime, you can use the
-p flag (e.g.,
docker run -p 800:80).
It’s useful to remember that the
docker network command supports creating networks for communication among containers without the need to expose or publish specific ports (See networking overview).
FROM instruction initialises a new build stage and sets the base image for subsequent instructions.
COPY [--chown=<user>:<group>] [--chmod=<perms>] <src>... <dest>
COPY instruction copies new files or directories from
<src> to the filesystem of the container at the path
All new files and directories are created with a UID and GID of 0, unless the optional
--chown flag specifies a specific username, groupname or UID/GID combination.
Important points to note:
<src>path must be inside the context of the build. You cannot
COPY ../something /something.
<dest>doesn’t exist, it is created along with all missing directories in its path.
Provides the default command for an executing container. In other words, it’s the default command that will execute when the container is started. If the user specifies an argument to
docker run <user-args...>, then they will override the default specified in
CMD ["executable","param1","param2"](exec form, this is the preferred form)
CMD ["param1","param2"](as default parameters to ENTRYPOINT)
CMD command param1 param2(shell form)
RUN instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile.
The default shell for the shell form can be changed using the
RUN <command>( the command is run in a shell, which by default is
/bin/sh -con Linux or
cmd /S /Con Windows) (shell form)
RUN ["executable", "param1", "param2"](exec form)