docker build
Dockerfile
Syntax
docker build [OPTIONS] PATH | URL | -
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
-t --tag |
and | docker build -t myapp:1.0 . |
Common |
-f --file |
Dockerfile | docker build -f Dockerfile.prod . |
Common |
--no-cache |
docker build --no-cache -t myapp . |
Common | |
--build-arg |
docker build --build-arg VERSION=1.0 . |
Advanced | |
--target |
docker build --target production . |
Advanced | |
--platform |
docker build --platform linux/amd64 . |
Advanced |
Examples
docker build -t myapp:latest .
.
Dockerfile
docker build -f docker/Dockerfile.prod -t myapp:prod .
Dockerfile
docker build --target builder -t myapp:build .
builder,
Parameters
docker build --build-arg NODE_VERSION=18 -t myapp .
Dockerfile ARG NODE_VERSION
Common Errors
failed to solve: failed to read dockerfile: open Dockerfile: no such file or directoryDockerfile, -f
COPY failed: file not found in build contextCOPY,.dockerignore
ERROR: failed to solve: process '/bin/sh -c xxx' did not complete successfullyRUN command, command,
Tips
- () Dockerfile,
- .dockerignore node_modules,.git and more