Dockerfile API Reference
Dockerfile instructions for building reproducible container images layer by layer.
Instructions
Declarative directives parsed top-to-bottom to assemble a container image.
FROM image[:tag] [AS stage]Sets the base image for subsequent instructions. Must be the first non-arg instruction.
Returns: void
RUN <command> | RUN ["exec", "arg1", ...]Executes a command in a new layer on top of the current image and commits the result.
Returns: void
COPY [--chown=user:group] src... destCopies new files or directories from the build context into the image filesystem.
Returns: void
WORKDIR pathSets the working directory for RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it.
Returns: void
ENV KEY=VALUESets an environment variable that persists in the built image and containers run from it.
Returns: void
EXPOSE port[/protocol]Documents which ports the container listens on at runtime. Does not publish the port.
Returns: void
CMD ["exec", "arg1", ...] | CMD command arg1 ...Provides default executable and arguments for the container. Overridable at runtime. Only the last CMD takes effect.
Returns: void
ENTRYPOINT ["exec", "arg1", ...]Configures the executable that always runs when the container starts. CMD arguments are appended.
Returns: void