Docker Build
Build images fast with BuildKit, tags, build args, and cache.
- docker build
- buildkit
- build arg
- dockerignore
- multi-stage
Docker Build
Build images fast with BuildKit, tags, build args, and cache.
Commands
| Command | What it does |
|---|---|
docker build -t app:v1 . | Build with a tag from current dir |
docker build --target prod -t app:v1 . | Build one multi-stage target |
docker build --build-arg VERSION=1.3 . | Pass a build-time variable |
docker build --no-cache -t app:v1 . | Force a clean rebuild |
docker history app:v1 | See layer sizes to find bloat |
Example
DOCKER_BUILDKIT=1 docker build --target prod -t registry/app:v1.3 .
docker history registry/app:v1.3 | head
FAQ
Why is my build slow?
Large contexts: add a .dockerignore (node_modules, .git) so the daemon receives kilobytes, not gigabytes.
How do build args differ from env?
ARG exists only at build time; use ENV (or --env at run) for runtime configuration.
常见问题
Why is my build slow?
Large contexts: add a .dockerignore (node_modules, .git) so the daemon receives kilobytes, not gigabytes.
How do build args differ from env?
ARG exists only at build time; use ENV (or --env at run) for runtime configuration.
Docker
Docker Install and Setup
Verify the Docker engine, configure context, and check versions.
Docker Images
Pull, list, tag, inspect, and remove images confidently.
Docker Containers
Run, list, stop, and clean up containers in daily work.
Docker Run Options
The flags that matter: detach, ports, env, volumes, limits.