Docker
Beginner
1 min read
Building Images with docker build
Example
# .dockerignore
# node_modules/
# .git/
# .env*
# *.log
# coverage/
# Build with default tag
docker build -t myapp:latest .
# Build with multiple tags
docker build -t myapp:2.1.0 -t myapp:latest .
# Build with build args
docker build \
--build-arg NODE_VERSION=20 \
--build-arg APP_VERSION=2.1.0 \
-t myapp:2.1.0 .
# Build without cache
docker build --no-cache -t myapp:latest .
# Build from a specific Dockerfile
docker build -f Dockerfile.prod -t myapp:prod .
# Enable BuildKit (faster, better caching)
DOCKER_BUILDKIT=1 docker build -t myapp:latest .
# View build history
docker history myapp:latest --no-trunc
Related Resources
Docker Reference
Complete tag & property list
Docker How-To Guides
Step-by-step practical guides
Docker Exercises
Practice what you've learned
More in Docker