Docker Build Reference

Complete reference for Dockerfile instructions, build commands, and best practices

Dockerfile Instructions

FROM

Sets the base image for subsequent instructions. The first instruction in a Dockerfile must be FROM.

View documentation →

COPY

Copies files or directories from source to the filesystem of the container at the specified path.

View documentation →

RUN

Executes commands in a new layer on top of the current image and commits the results.

View documentation →

CMD

Provides default commands and arguments for an executing container. There can only be one CMD per Dockerfile.

View documentation →

ENTRYPOINT

Configures a container that will run as an executable, and allows you to configure a container to run as an executable.

View documentation →

ENV

Sets environment variables in the image for both building and runtime of the containerized application.

View documentation →

Build Concepts

Multi-stage Builds

Create smaller and more efficient images by using multiple stages to separate build and runtime environments.

View documentation →

Build Context

Understand the build context, the set of files available to Docker during the build process.

View documentation →

Layer Caching

Learn how Docker's build cache works and how to optimize your builds for better caching.

View documentation →

Command Line Reference

docker build

Build an image from a Dockerfile with detailed options and examples.

View documentation →

docker image

Manage Docker images, including listing, tagging, and removing images.

View documentation →

docker push/pull

Push images to a registry and pull images from a registry.

View documentation →