docker build

Build a Docker image from a Dockerfile.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

docker build creates images from a Dockerfile. The -t flag tags the image. Build context (the path argument) is sent to the Docker daemon — use .dockerignore to exclude unnecessary files and speed up builds.

Common flags
FlagMeaning
-t --tagName and optionally tag the image
-f --filePath to Dockerfile
--no-cacheBuild without using cache
--build-argSet build-time variables
--platformTarget platform (e.g., linux/amd64,linux/arm64)
Examples
docker build -t myapp:v1.2.3 .Build and tag image from current directory · explain & risk-check →
docker build --no-cache -t myapp:latest .Force clean build ignoring cache · explain & risk-check →
docker build --platform linux/amd64,linux/arm64 -t myapp:latest .Multi-platform build · explain & risk-check →
docker build --build-arg ENV=production -t myapp:prod .Pass build argument · explain & risk-check →
Pro tip

Order Dockerfile instructions from least to most frequently changing — COPY requirements.txt and RUN pip install before COPY . . — to maximize cache layer reuse and reduce build times.

Related
docker ps docker logs docker exec
Open the full explainer →More in Docker & Containers

Reference text is hand-written and may be incomplete — check man docker for your version. Test destructive commands on a non-production system first.