# googlecontainertools/kaniko architecture

> Architecture diagram of the GitHub repository googlecontainertools/kaniko, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/googlecontainertools/kaniko
- Repository: https://github.com/googlecontainertools/kaniko

## Overview

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: [`pkg/executor/build.go`](https://github.com/googlecontainertools/kaniko/blob/main/pkg/executor/build.go) (Stage executor), [`cmd/executor/cmd/root.go`](https://github.com/googlecontainertools/kaniko/blob/main/cmd/executor/cmd/root.go) (Executor CLI), [`pkg/executor/push.go`](https://github.com/googlecontainertools/kaniko/blob/main/pkg/executor/push.go) (Image push), [`cmd/warmer/cmd/root.go`](https://github.com/googlecontainertools/kaniko/blob/main/cmd/warmer/cmd/root.go) (Warmer CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Commands"]
  node_executor_cmd["Executor CLI<br/>[root.go]"]
  node_warmer_cmd["Warmer CLI<br/>[root.go]"]
end

subgraph group_inputs["Build inputs"]
  node_context["Context sources"]
  node_dockerfile["Dockerfile stages<br/>[dockerfile.go]"]
  node_config["Build configuration"]
end

subgraph group_build["Image construction"]
  node_builder["Stage executor<br/>[build.go]"]
  node_commands["Instruction handlers"]
end

subgraph group_artifacts["Images and cache"]
  node_base_image["Base image retrieval<br/>[image_util.go]"]
  node_remote_image["Remote images<br/>[remote.go]"]
  node_layer_cache[("Layer cache<br/>[cache.go]")]
  node_warmer["Cache warming<br/>[warm.go]"]
  node_push["Image push<br/>[push.go]"]
end

subgraph group_internals["Filesystem internals"]
  node_snapshot["Filesystem snapshots<br/>[snapshot.go]"]
  node_filesystem["Filesystem utilities<br/>[fs_util.go]"]
end

node_user(("Build operator"))
node_registry[("Image registry")]
node_image_result[("Built image")]

node_user -->|"configures build"| node_executor_cmd
node_executor_cmd -->|"selects context"| node_context
node_executor_cmd -->|"sets options"| node_config
node_executor_cmd -->|"starts build"| node_builder
node_context -.->|"provides files"| node_builder
node_builder -->|"parses stages"| node_dockerfile
node_builder -->|"uses options"| node_config
node_builder -->|"retrieves base"| node_base_image
node_base_image -->|"retrieves remotely"| node_remote_image
node_remote_image -.->|"pulls image"| node_registry
node_builder -->|"executes instructions"| node_commands
node_commands -->|"changes files"| node_filesystem
node_builder -->|"snapshots changes"| node_snapshot
node_snapshot -->|"walks files"| node_filesystem
node_builder -->|"checks and stores layers"| node_layer_cache
node_builder -.->|"pushes image"| node_push
node_push -.->|"publishes image"| node_registry
node_push -.->|"produces image"| node_image_result
node_user -.->|"requests warming"| node_warmer_cmd
node_warmer_cmd -.->|"warms cache"| node_warmer
node_warmer -.->|"populates cache"| node_layer_cache

click node_executor_cmd "https://github.com/googlecontainertools/kaniko/blob/main/cmd/executor/cmd/root.go"
click node_warmer_cmd "https://github.com/googlecontainertools/kaniko/blob/main/cmd/warmer/cmd/root.go"
click node_context "https://github.com/googlecontainertools/kaniko/tree/main/pkg/buildcontext"
click node_dockerfile "https://github.com/googlecontainertools/kaniko/blob/main/pkg/dockerfile/dockerfile.go"
click node_config "https://github.com/googlecontainertools/kaniko/tree/main/pkg/config"
click node_builder "https://github.com/googlecontainertools/kaniko/blob/main/pkg/executor/build.go"
click node_commands "https://github.com/googlecontainertools/kaniko/tree/main/pkg/commands"
click node_base_image "https://github.com/googlecontainertools/kaniko/blob/main/pkg/image/image_util.go"
click node_remote_image "https://github.com/googlecontainertools/kaniko/blob/main/pkg/image/remote/remote.go"
click node_snapshot "https://github.com/googlecontainertools/kaniko/blob/main/pkg/snapshot/snapshot.go"
click node_filesystem "https://github.com/googlecontainertools/kaniko/blob/main/pkg/util/fs_util.go"
click node_layer_cache "https://github.com/googlecontainertools/kaniko/blob/main/pkg/cache/cache.go"
click node_warmer "https://github.com/googlecontainertools/kaniko/blob/main/pkg/cache/warm.go"
click node_push "https://github.com/googlecontainertools/kaniko/blob/main/pkg/executor/push.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_executor_cmd,node_warmer_cmd toneBlue
class node_context,node_dockerfile,node_config,node_registry,node_image_result toneAmber
class node_builder,node_commands toneMint
class node_base_image,node_remote_image,node_layer_cache,node_warmer,node_push toneRose
class node_snapshot,node_filesystem,node_user toneIndigo
```

## Components

### Commands

- [Executor CLI](https://github.com/googlecontainertools/kaniko/blob/main/cmd/executor/cmd/root.go): `cmd/executor/cmd/root.go`
- [Warmer CLI](https://github.com/googlecontainertools/kaniko/blob/main/cmd/warmer/cmd/root.go): `cmd/warmer/cmd/root.go`

### Build inputs

- [Context sources](https://github.com/googlecontainertools/kaniko/tree/main/pkg/buildcontext): `pkg/buildcontext`
- [Dockerfile stages](https://github.com/googlecontainertools/kaniko/blob/main/pkg/dockerfile/dockerfile.go): `pkg/dockerfile/dockerfile.go`
- [Build configuration](https://github.com/googlecontainertools/kaniko/tree/main/pkg/config): `pkg/config`

### Image construction

- [Stage executor](https://github.com/googlecontainertools/kaniko/blob/main/pkg/executor/build.go): `pkg/executor/build.go`
- [Instruction handlers](https://github.com/googlecontainertools/kaniko/tree/main/pkg/commands): `pkg/commands`

### Images and cache

- [Base image retrieval](https://github.com/googlecontainertools/kaniko/blob/main/pkg/image/image_util.go): `pkg/image/image_util.go`
- [Remote images](https://github.com/googlecontainertools/kaniko/blob/main/pkg/image/remote/remote.go): `pkg/image/remote/remote.go`
- [Layer cache](https://github.com/googlecontainertools/kaniko/blob/main/pkg/cache/cache.go): `pkg/cache/cache.go`
- [Cache warming](https://github.com/googlecontainertools/kaniko/blob/main/pkg/cache/warm.go): `pkg/cache/warm.go`
- [Image push](https://github.com/googlecontainertools/kaniko/blob/main/pkg/executor/push.go): `pkg/executor/push.go`

### Filesystem internals

- [Filesystem snapshots](https://github.com/googlecontainertools/kaniko/blob/main/pkg/snapshot/snapshot.go): `pkg/snapshot/snapshot.go`
- [Filesystem utilities](https://github.com/googlecontainertools/kaniko/blob/main/pkg/util/fs_util.go): `pkg/util/fs_util.go`

### Other components

- **Build operator**
- **Image registry**
- **Built image**

## Connections

- Build operator → Executor CLI: configures build
- Executor CLI → Context sources: selects context (evidence: `cmd/executor/cmd/root.go`)
- Executor CLI → Build configuration: sets options (evidence: `cmd/executor/cmd/root.go`)
- Executor CLI → Stage executor: starts build (evidence: `cmd/executor/cmd/root.go`)
- Context sources → Stage executor: provides files
- Stage executor → Dockerfile stages: parses stages (evidence: `pkg/executor/build.go`)
- Stage executor → Build configuration: uses options (evidence: `pkg/executor/build.go`)
- Stage executor → Base image retrieval: retrieves base (evidence: `pkg/executor/build.go`)
- Base image retrieval → Remote images: retrieves remotely (evidence: `pkg/image/image_util.go`)
- Remote images → Image registry: pulls image
- Stage executor → Instruction handlers: executes instructions (evidence: `pkg/executor/build.go`)
- Instruction handlers → Filesystem utilities: changes files (evidence: `pkg/commands/copy.go`)
- Stage executor → Filesystem snapshots: snapshots changes (evidence: `pkg/executor/build.go`)
- Filesystem snapshots → Filesystem utilities: walks files (evidence: `pkg/snapshot/snapshot.go`)
- Stage executor → Layer cache: checks and stores layers (evidence: `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
