How googlecontainertools/kaniko works
kaniko builds container images from Dockerfiles in userspace, without a Docker daemon. The executor takes a context and build options, parses staged instructions, retrieves base images, executes commands, snapshots filesystem changes into layers, and pushes the result; caching and the separate cache-warmer command support that workflow. The README documents the overall build-and-push flow and multiple context and registry options. Some implementation files were not sampled, so their internal wiring is omitted or marked unverified.
Main entry points: build.go Stage executor · cmd/root.go Executor CLI · push.go Image push · cmd/root.go Warmer CLI
Components 17
Commands
- Executor CLI
cmd/executor/cmd/root.go - Warmer CLI
cmd/warmer/cmd/root.go
Build inputs
- Context sources
pkg/buildcontext - Dockerfile stages
pkg/dockerfile/dockerfile.go - Build configuration
pkg/config
Image construction
- Stage executor
pkg/executor/build.go - Instruction handlers
pkg/commands
Images and cache
- Base image retrieval
pkg/image/image_util.go - Remote images
pkg/image/remote/remote.go - Layer cache
pkg/cache/cache.go - Cache warming
pkg/cache/warm.go - Image push
pkg/executor/push.go
Filesystem internals
- Filesystem snapshots
pkg/snapshot/snapshot.go - Filesystem utilities
pkg/util/fs_util.go
Other components
- Build operator
- Image registry
- Built image
Connections 21
- Build operator → Executor CLI: configures build
- Executor CLI → Context sources: selects context
cmd/executor/cmd/root.go - Executor CLI → Build configuration: sets options
cmd/executor/cmd/root.go - Executor CLI → Stage executor: starts build
cmd/executor/cmd/root.go - Context sources → Stage executor: provides files
- Stage executor → Dockerfile stages: parses stages
pkg/executor/build.go - Stage executor → Build configuration: uses options
pkg/executor/build.go - Stage executor → Base image retrieval: retrieves base
pkg/executor/build.go - Base image retrieval → Remote images: retrieves remotely
pkg/image/image_util.go - Remote images → Image registry: pulls image
- Stage executor → Instruction handlers: executes instructions
pkg/executor/build.go - Instruction handlers → Filesystem utilities: changes files
pkg/commands/copy.go - Stage executor → Filesystem snapshots: snapshots changes
pkg/executor/build.go - Filesystem snapshots → Filesystem utilities: walks files
pkg/snapshot/snapshot.go - Stage executor → Layer cache: checks and stores layers
pkg/executor/build.go - Stage executor → Image push: pushes image
- Image push → Image registry: publishes image
- Image push → Built image: produces image
- Build operator → Warmer CLI: requests warming
- Warmer CLI → Cache warming: warms cache
- Cache warming → Layer cache: populates cache