Apko: Container Image Builder
Table of Contents
TL;DR #
Ever wonder how to build your own Wolfi base images?
apko is Chainguard’s declarative container image builder that replaces Dockerfiles with YAML configuration. Instead of imperative RUN
commands, you declare packages, users, and filesystem layout — apko handles the rest.
The result? Single-layer images built directly from APK packages with automatic SBOM generation and multi-arch support. Perfect for security-conscious teams building reproducible base images, though it can’t replace Docker entirely for complex application builds.
Basic Usage #
Let’s jump right into the practical stuff — we’ll cover the ‘why apko?’ discussion after you see it in action.
Nginx image #
|
|
Syntax: check schema https://raw.githubusercontent.com/chainguard-dev/apko/main/pkg/build/types/schema.json for all the reference
Build Process #
|
|
Supply Chain Features #
|
|
🤯 Yup, Zero vulnerabilities detected
Reproducibility #
|
|
Lockfile Workflow #
|
|
The Declarative Advantage #
The declarative advantage — apko configurations are deterministic blueprints rather than imperative scripts. No more layer cache mysteries or “works on my machine” builds.
Notice how the nginx example above contains zero shell scripts? That’s apko’s strength and limitation rolled into one. You define what packages you want, not how to install them. This makes apko excellent for creating secure base images like Python or Node.js containers, but it can’t replace Docker entirely — complex application builds still need imperative steps.
The foundation difference is key here. Traditional containers start with bloated base images like Ubuntu or Alpine. apko starts with wolfi-baselayout
— just the essential Linux filesystem structure. Everything else is explicitly declared packages.
Single-layer simplicity eliminates Docker’s layer caching complexity. Your YAML config becomes a pure package-to-image transformation. Reproducible by design — lock your package versions once, build identically across all environments and architectures.
Supply chain transparency comes built-in through automatic SBOM generation and package verification. Every dependency is tracked, signed, and auditable — critical for security-conscious deployments.
Will I Actually Use It? #
For building applications, apko adds a complexity layer — the short answer is yes, but selectively.
I previously maintained a dedicated repository in my organization just for building all the base images used across GitLab CI and application deployments. apko would be perfect for that use case — standardized, reproducible base images with built-in security scanning.