The syntax is mostly as following:
# parser directives
ARG arg_name=arg_val
FROM image:tag
# env_variable persists in image
ENV env_variable
# Override the shell that is used to run commands.
SHELL ["<shell>", "<arg1>", ...]
# General syntax for command:
# command := <command> <arg1> ...
# := <shell command>
# := ["<command>", "<arg1>", ...]
# The first two are run via SHELL.
# command is essentially any arbitrary shell command.
RUN command
# variable will not be in the final image
RUN env_variable=val command
# Perform only this RUN instruction with the env_variable defined using ARG.
# i.e: the definitions from ARG will go out of scope after this build step.
ARG env_variable=val
RUN command
# this user is used for RUN, CMD, and ENTRYPOINT instructions below
USER user[:group]
# copy files/dirs from src uri pattern to dest directory in image.
ADD [--chown=user:group] src dest
# defines where a particular volume must be mounted, doesn't actually mount it.
VOLUME volume_locations
# default command to run the container with
ENTRYPOINT command
# Mostly a documentation it seems
EXPOSE port[/protocol]
# register a command to run the container with
CMD command
# NONE disables HEALTHCHECK (even that of the base image).
HEALTHCHECK [NONE | CMD command]
# The way ENTRYPOINT, CMD, and --entrypoint interact is slightly
# complex consult docs:
# docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact
# Run the instruction when building the image.
ONBUILD <Instruction>
Refer docs for a much more in-depth documentation.