DockerSelf-Hosting

Distroless and Wolfi: Small, Safer Base Images for Your Own Docker Builds (Linux, Windows, Mac)

Before you start

  • 27 min read

Boxes marked Run in terminal are what you type; plain text explains why. Check what you need first

What you get in one minute#

Distroless and Wolfi are two ways to ship your own app in a very small image that has no shell, no package manager and no extra tools, so there is less to attack and less for a scanner to complain about. You build with the full tools in one stage, then copy only the finished program into the small image.

Wolfi official logo

Logo: the official Wolfi project (github.com/wolfi-dev/.github). The file has no licence of its own; the Wolfi build recipes are Apache-2.0. Distroless (Google) has no official logo, so only Wolfi is shown here.

We build a Go web service on distroless and on Chainguard's Wolfi images, pin the base by digest, debug without a shell and scan the result.

WhatValue (official sources, read 5 December 2026)
DistrolessNo release numbers; images are tagged -debian13 (newest push 22 November 2026, registry tag list). Apache-2.0
WolfiRolling package set. Recipes Apache-2.0. apko v1.5.7 (4 December 2026) and melange v0.66.1 (3 December 2026), both Apache-2.0
Builder we pingolang:1.27.4-trixie (Docker Hub, pushed 1 December 2026; newest stable Go on go.dev)
Scanner we pinaquasec/trivy:0.77.0; checked 5 December 2026
Time neededAbout 45 minutes (our estimate)
Download size, amd64, compresseddistroless static nonroot 0.82 MiB, base 9.06 MiB; Chainguard static 0.43 MiB, glibc-dynamic 4.60 MiB, wolfi-base 7.80 MiB (layers added up from each registry manifest)
Port8080 for our demo app, on 127.0.0.1
Official docsdistroless, Wolfi, Chainguard Containers

At a glance:

  • Distroless (Google): Debian's libraries and certificates, nothing else. Free, no account, on gcr.io.
  • Wolfi: a small Linux "undistro" for containers. Chainguard sells hardened images made from it; a few are free.
  • No shell in either. You cannot docker exec ... sh; Step 6 shows the other ways in.
  • Pin by digest, then update on purpose.
  • Scanners: fewer packages mean fewer findings, not zero forever.
  • Nothing was run on a real machine. Commands come from the official docs; image data from the registries' web APIs on 5 December 2026.

How it fits together#

A multi-stage Dockerfile builds your program in a stage with a compiler and shell, then copies only that one file into a tiny image. The first stage is thrown away.

Flow of a multi-stage build: your source code goes into a builder image with a compiler and shell, one built file is copied into a small runtime image (distroless static or Chainguard static) that has no shell, the container runs read-only on your Docker host, scan and verify tools check the image, and a debug sidecar is used only when needed

Drawn for this guide from the official docs. Dashed boxes are optional or discarded.

Words you will meet: Wolfi is the package set Chainguard's images are made of (no kernel of its own). apko builds an image from a YAML list of packages; melange builds the packages. A digest is the fingerprint (sha256:...) of the exact image behind a tag; a tag can move, a digest cannot.

Which distroless image fits your program (from the project's docs):

Your programPickWhat is inside
Go with CGO_ENABLED=0, Rust musl, anything staticstatic-debian13CA certificates, tzdata, a /tmp folder, user entries
Needs glibc but not OpenSSLbase-nossl-debian13the above plus glibc
Needs glibc and OpenSSL (Go with cgo)base-debian13the above plus libssl
Rust or D, mostly staticcc-debian13base plus libgcc
Java, Node.js, Pythonjava21-debian13, nodejs24-debian13, python3-debian13 and otherscc plus the runtime

Every image has four tags: latest, nonroot, debug and debug-nonroot. The nonroot ones run as user 65532 (from the image configuration in the registry). The debug ones add a busybox shell.

Before you start#

Note: every domain, digest and password on this page is a dummy example (like demo.example.com or change-me). Replace it with your own, and keep real secrets out of Git.

SystemWhat to have
LinuxDocker Engine with the Compose plugin and Buildx
WindowsWindows 10 or later, Docker Desktop (WSL 2 backend, Linux containers), PowerShell
MacDocker Desktop, Intel or Apple Silicon
Run in terminalbash
docker --version
docker compose version
docker buildx version

Both registries are public and need no login for what we use (we read their tag lists anonymously). The static images exist for amd64 and arm64, so Apple Silicon works too.

Checklist:

  • [ ] The three commands above print a version
  • [ ] Port 8080 is free on 127.0.0.1
  • [ ] Only for the HTTPS part: a domain, DNS and ports 80 and 443

Tested on 2026-12-05: Linux = not run, Windows = not run, Mac = not run. Everything comes from the official docs and the registries' APIs.

LLM Guide: let your AI assistant set it up#

Prefer to let an AI do the typing? Copy the block below into ChatGPT, Claude, Gemini or a local model. It first asks about your setup (system, Docker, reverse proxy, HTTPS), then follows only the path that fits you. It uses the same pinned versions as this guide. You still read each command before you run it.

Instructions for your AI assistantllm
You are my assistant for building a tiny container image for my own app on distroless (Google) and on Wolfi (Chainguard) base images, with no shell inside.
Follow the DIY Lab Hub guide https://diylabhub.com/distroless-wolfi/ (checked 5 December 2026).
Work one step at a time. Before each command, say in one line what it does. Wait for my OK before anything that deletes data, stops a service, changes a firewall or opens a port.

STEP 0 - FIND OUT MY SETUP. Ask me these questions (or have me run the read-only checks) before you do anything else:
1. Which machine: Linux (which distribution), Windows (Docker Desktop, WSL 2, Linux containers) or Mac (Intel or Apple Silicon)?
2. Are Docker, the Compose plugin and Buildx installed? Check: docker --version, docker compose version, docker buildx version
3. Is port 8080 free on 127.0.0.1?
4. Do I want to use the guide's demo Go app, or my own program? (A static Go program with CGO_ENABLED=0 fits distroless "static"; a program that needs glibc fits "base-nossl" or "base"; Java, Node.js and Python have their own distroless images.)
5. Distroless only, Wolfi (Chainguard) only, or both so I can compare?
6. Is the container only for this computer, or published behind a reverse proxy (Traefik, Caddy, nginx / Nginx Proxy Manager, none) with HTTPS on a public domain or at home only?

THEN FOLLOW THE MATCHING PATH:
- Docker missing: install Docker Engine + Compose plugin + Buildx (Linux) or Docker Desktop (Windows/Mac) from docs.docker.com first.
- This computer only: use the Compose file below as it is (it binds to 127.0.0.1).
- Traefik already running on the external "proxy" network: remove the ports block, join the "proxy" network and add these labels (the domain is an example):
    traefik.enable=true
    traefik.docker.network=proxy
    traefik.http.routers.hello.rule=Host(`demo.example.com`)
    traefik.http.routers.hello.entrypoints=https
    traefik.http.routers.hello.tls=true
    traefik.http.routers.hello.tls.certresolver=le
    traefik.http.services.hello.loadbalancer.server.port=8080
- No proxy but I want HTTPS: use Caddy 2.11.9 as in the guide's HTTPS section (own folder ~/docker_volumes/caddy with conf, data, config; ports 80, 443/tcp, 443/udp; shared network "proxy"). Caddyfile "demo.example.com { reverse_proxy distroless-demo:8080 }"; Let's Encrypt for a public domain (DNS record, ports 80 and 443 open), "tls internal" for a home-only name, then trust Caddy's root certificate on my own devices.
- nginx / Nginx Proxy Manager: proxy only container port 8080.
- Wolfi: use Dockerfile.wolfi below (the guide's pattern: Go builder with a shell, static runtime). Tell me the guide's advice to pin the base image by digest (docker buildx imagetools inspect <image>), at the price of no automatic security fixes.

THE FILES (folder ~/docker_volumes/distroless-demo with app, config, backups; Windows: $HOME\docker_volumes\distroless-demo; write files as UTF-8 without BOM):
Linux/Mac: mkdir -p ~/docker_volumes/distroless-demo/{app,config,backups}
app/go.mod:
module example.com/hello

go 1.27
app/main.go:
package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	probe := flag.Bool("healthcheck", false, "ask the running server if it is healthy, then exit")
	flag.Parse()

	if *probe {
		client := http.Client{Timeout: 2 * time.Second}
		resp, err := client.Get("http://127.0.0.1:8080/healthz")
		if err != nil || resp.StatusCode != http.StatusOK {
			os.Exit(1)
		}
		return
	}

	mux := http.NewServeMux()
	mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "ok")
	})
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "Hello from a container with no shell")
	})
	srv := &http.Server{Addr: ":8080", Handler: mux, ReadHeaderTimeout: 5 * time.Second}
	log.Fatal(srv.ListenAndServe())
}
app/Dockerfile (keep these exact versions):
# syntax=docker/dockerfile:1
FROM golang:1.27.4-trixie AS build
WORKDIR /src
COPY go.mod main.go ./
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/hello .

# Same app plus a busybox shell. For debugging only: docker build --target debug
FROM gcr.io/distroless/static-debian13:debug-nonroot AS debug
COPY --from=build /out/hello /hello
ENTRYPOINT ["/hello"]

# What you ship
FROM gcr.io/distroless/static-debian13:nonroot AS final
COPY --from=build /out/hello /hello
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["/hello", "-healthcheck"]
ENTRYPOINT ["/hello"]
app/Dockerfile.wolfi (only if I want Wolfi):
# syntax=docker/dockerfile:1
FROM cgr.dev/chainguard/go:latest-dev AS build
WORKDIR /src
COPY go.mod main.go ./
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/hello .

FROM cgr.dev/chainguard/static:latest AS final
COPY --from=build /out/hello /hello
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["/hello", "-healthcheck"]
ENTRYPOINT ["/hello"]
compose.yaml (next to app):
services:
  hello:
    image: distroless-demo:1.0.0
    build:
      context: ./app
    container_name: distroless-demo
    restart: unless-stopped
    read_only: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    ports:
      - "127.0.0.1:8080:8080"
Build and start: docker compose build   then: docker compose up -d
Wolfi build: docker build --pull -f Dockerfile.wolfi -t distroless-demo:1.0.0-wolfi .  (run in the app folder)

CHECK IT WORKED:
- docker compose ps shows distroless-demo running; curl -s http://127.0.0.1:8080/ prints "Hello from a container with no shell" (Windows: curl.exe).
- docker inspect --format '{{.State.Health.Status}}' distroless-demo becomes healthy.
- There is no shell: docker exec distroless-demo sh fails. To debug use docker logs distroless-demo --tail 100, or build the debug stage: docker build --target debug -t distroless-demo:1.0.0-debug ./app
- Scan (optional): docker run --rm -i hadolint/hadolint:v2.15.1 < app/Dockerfile ; docker save distroless-demo:1.0.0 -o scan/demo.tar ; docker run --rm -v trivy-cache:/root/.cache -v "$PWD/scan":/work aquasec/trivy:0.77.0 image --input /work/demo.tar . Fewer packages mean fewer findings, not zero; do not promise "zero CVEs".

RULES FOR YOU:
- Use only the versions and settings above. Do not switch to :latest for the builder or the distroless images and do not invent options; on an error show me the exact text and check https://github.com/GoogleContainerTools/distroless before guessing.
- Never publish the port to the internet without HTTPS. Keep secrets out of the image and out of Git.
- Values like demo.example.com are examples; ask me for mine.
- Never ask me to paste passwords, tokens or keys into this chat.

Step 1: Create the folders and a tiny app#

Everything lives under ~/docker_volumes/distroless-demo. The demo keeps no data; backups is for the backup script later. Our app is a Go web service with a -healthcheck option, because a container with no shell and no curl needs its own health probe (see the first mistake in the table below).

Linux#

Run in terminalbash
mkdir -p ~/docker_volumes/distroless-demo/{app,config,backups}
cd ~/docker_volumes/distroless-demo/app
cat > go.mod << 'EOF'
module example.com/hello

go 1.27
EOF
cat > main.go << 'EOF'
package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	probe := flag.Bool("healthcheck", false, "ask the running server if it is healthy, then exit")
	flag.Parse()

	if *probe {
		client := http.Client{Timeout: 2 * time.Second}
		resp, err := client.Get("http://127.0.0.1:8080/healthz")
		if err != nil || resp.StatusCode != http.StatusOK {
			os.Exit(1)
		}
		return
	}

	mux := http.NewServeMux()
	mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "ok")
	})
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "Hello from a container with no shell")
	})
	srv := &http.Server{Addr: ":8080", Handler: mux, ReadHeaderTimeout: 5 * time.Second}
	log.Fatal(srv.ListenAndServe())
}
EOF

Windows (PowerShell)#

Codepowershell
$base = "$HOME\docker_volumes\distroless-demo"
foreach ($d in "app","config","backups") { New-Item -ItemType Directory -Force "$base\$d" | Out-Null }
Set-Location "$base\app"
@'
module example.com/hello

go 1.27
'@ | Set-Content -Encoding ascii go.mod
@'
package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	probe := flag.Bool("healthcheck", false, "ask the running server if it is healthy, then exit")
	flag.Parse()

	if *probe {
		client := http.Client{Timeout: 2 * time.Second}
		resp, err := client.Get("http://127.0.0.1:8080/healthz")
		if err != nil || resp.StatusCode != http.StatusOK {
			os.Exit(1)
		}
		return
	}

	mux := http.NewServeMux()
	mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "ok")
	})
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintln(w, "Hello from a container with no shell")
	})
	srv := &http.Server{Addr: ":8080", Handler: mux, ReadHeaderTimeout: 5 * time.Second}
	log.Fatal(srv.ListenAndServe())
}
'@ | Set-Content -Encoding ascii main.go

Mac (Terminal)#

Same commands as Linux.

Check it worked. ls (Windows: Get-ChildItem) in the app folder shows go.mod and main.go. You do not need Go on your machine: the build stage brings it.

Step 2: Build on distroless#

The Dockerfile has three stages. build compiles. debug is the same app on the debug-nonroot base, only for Step 6. final is what you ship, and because it is last, it is the default.

Linux#

Run in terminalbash
cd ~/docker_volumes/distroless-demo/app
cat > Dockerfile << 'EOF'
# syntax=docker/dockerfile:1
FROM golang:1.27.4-trixie AS build
WORKDIR /src
COPY go.mod main.go ./
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/hello .

# Same app plus a busybox shell. For debugging only: docker build --target debug
FROM gcr.io/distroless/static-debian13:debug-nonroot AS debug
COPY --from=build /out/hello /hello
ENTRYPOINT ["/hello"]

# What you ship
FROM gcr.io/distroless/static-debian13:nonroot AS final
COPY --from=build /out/hello /hello
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["/hello", "-healthcheck"]
ENTRYPOINT ["/hello"]
EOF
cd ..
cat > compose.yaml << 'EOF'
services:
  hello:
    image: distroless-demo:1.0.0
    build:
      context: ./app
    container_name: distroless-demo
    restart: unless-stopped
    read_only: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    ports:
      - "127.0.0.1:8080:8080"
EOF
docker compose build

Windows (PowerShell)#

Codepowershell
Set-Location "$HOME\docker_volumes\distroless-demo\app"
@'
# syntax=docker/dockerfile:1
FROM golang:1.27.4-trixie AS build
WORKDIR /src
COPY go.mod main.go ./
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/hello .

# Same app plus a busybox shell. For debugging only: docker build --target debug
FROM gcr.io/distroless/static-debian13:debug-nonroot AS debug
COPY --from=build /out/hello /hello
ENTRYPOINT ["/hello"]

# What you ship
FROM gcr.io/distroless/static-debian13:nonroot AS final
COPY --from=build /out/hello /hello
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["/hello", "-healthcheck"]
ENTRYPOINT ["/hello"]
'@ | Set-Content -Encoding ascii Dockerfile
Set-Location ..
@'
services:
  hello:
    image: distroless-demo:1.0.0
    build:
      context: ./app
    container_name: distroless-demo
    restart: unless-stopped
    read_only: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    ports:
      - "127.0.0.1:8080:8080"
'@ | Set-Content -Encoding ascii compose.yaml
docker compose build

Mac (Terminal)#

Same commands as Linux.

The less obvious lines:

LineWhy
CGO_ENABLED=0A fully static program; static has no C library
golang:1.27.4-trixieTrixie is Debian 13, the same generation as the base (see the glibc row in Common mistakes)
:nonrootRuns as user 65532, not root
Array formNo shell can read a shell-form line (README)
read_only, cap_drop, no-new-privilegesOur additions, not from the distroless docs

Check it worked. docker compose build ends without an error and docker image ls distroless-demo lists 1.0.0. We did not run it, so we show no sizes; our measured base sizes are in the table at the top.

Step 3: Run it and look at the health check#

Linux#

Run in terminalbash
cd ~/docker_volumes/distroless-demo
docker compose up -d
docker compose ps
curl -s http://127.0.0.1:8080/
docker inspect --format '{{.State.Health.Status}}' distroless-demo

Windows (PowerShell)#

Codepowershell
Set-Location "$HOME\docker_volumes\distroless-demo"
docker compose up -d
docker compose ps
curl.exe -s http://127.0.0.1:8080/
docker inspect --format '{{.State.Health.Status}}' distroless-demo

Mac (Terminal)#

Same commands as Linux.

Check it worked. The page prints Hello from a container with no shell. The health status is first starting and, after the probe passes, healthy (Docker's documented states are starting, healthy and unhealthy). We did not run it.

Now see what "no shell" means. This should fail:

Run in terminalbash
docker exec -it distroless-demo sh

Expect an error of this kind. The wording varies by Docker version; this text is from Chainguard's own debugging docs for a shell-less image: exec: "sh": executable file not found in $PATH: unknown. That is correct behaviour, not a bug.

Tip: A HEALTHCHECK with curl or CMD-SHELL cannot work here: both need /bin/sh or curl. Use the exec form and a probe inside your program, as we did (issue 183).

Step 4: The same app on Wolfi (Chainguard images)#

Same idea. The builder is cgr.dev/chainguard/go:latest-dev (shell and Go toolchain); the runtime is cgr.dev/chainguard/static:latest. Chainguard's own Go guide uses this pattern.

Linux#

Run in terminalbash
cd ~/docker_volumes/distroless-demo/app
cat > Dockerfile.wolfi << 'EOF'
# syntax=docker/dockerfile:1
FROM cgr.dev/chainguard/go:latest-dev AS build
WORKDIR /src
COPY go.mod main.go ./
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/hello .

FROM cgr.dev/chainguard/static:latest AS final
COPY --from=build /out/hello /hello
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["/hello", "-healthcheck"]
ENTRYPOINT ["/hello"]
EOF
docker build --pull -f Dockerfile.wolfi -t distroless-demo:1.0.0-wolfi .
docker image ls distroless-demo

Windows (PowerShell)#

Codepowershell
Set-Location "$HOME\docker_volumes\distroless-demo\app"
@'
# syntax=docker/dockerfile:1
FROM cgr.dev/chainguard/go:latest-dev AS build
WORKDIR /src
COPY go.mod main.go ./
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/hello .

FROM cgr.dev/chainguard/static:latest AS final
COPY --from=build /out/hello /hello
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["/hello", "-healthcheck"]
ENTRYPOINT ["/hello"]
'@ | Set-Content -Encoding ascii Dockerfile.wolfi
docker build --pull -f Dockerfile.wolfi -t distroless-demo:1.0.0-wolfi .
docker image ls distroless-demo

Mac (Terminal)#

Same commands as Linux.

Check it worked. Both tags (1.0.0 and 1.0.0-wolfi) are listed. To run the Wolfi one, stop the first container (docker compose down) and use docker run --rm -p 127.0.0.1:8080:8080 distroless-demo:1.0.0-wolfi.

From the registry configuration on 5 December 2026: Chainguard static runs as user 65532; go runs as root with /usr/bin/go as entrypoint, fine for a build stage you throw away. We did not check which Go version go:latest-dev carries; if it is older than 1.27, lower the go line in go.mod.

Which one? Distroless has no account and dated tags. Chainguard rebuilds nightly (its docs), but the free images only have latest. For least friction at home, start with distroless.

What Chainguard gives for free (and what it does not)#

This changed recently and many pages online are out of date. Sources: Chainguard's own docs, read on 5 December 2026.

PlanWhat you getSource and date
Free public imagescgr.dev/chainguard/<image>, no login. Only the latest build, tagged latest and latest-devContainer categories page, October 2026
Starter, $0An account; you pick five images, all supported versions of those. Marked beta. A chosen image cannot be swapped. CI pull tokens last 30 days by default. No CVE SLAStarter page, December 2026; pricing page
Team, $500 a monthMore images and downloads, image swapsPricing page
EnterpriseFIPS, custom assembly, SLAs, SSOPricing page

We checked in the registry API, anonymously: cgr.dev/chainguard/go lists only latest and latest-dev, and a request for cgr.dev/chainguard/python:3.12 answers {"errors":[{"code":"MANIFEST_UNKNOWN","message":"Unknown manifest"}]}. A pinned version tag is not in the free set.

What this means for you:

  • Reproducible builds need a digest. latest moves every night: cgr.dev/chainguard/static:latest@sha256:<digest> (Step 5).
  • No uptime promise. The registry page says there is no SLA and suggests a pull-through cache. At home, keep a copy in your own registry (Docker registry, Skopeo).
  • The free list can change. Our research cited a Chainguard support notice of 16 November 2026 about free-tier changes, but its page asked for a browser check and we could not read it. Check the current rules before you depend on an image.

Wolfi itself is free under Apache-2.0 "and will always be" (Wolfi FAQ). But Chainguard removes package definitions it stops building, and non-latest versions are kept for 6 months, so an apk add python-3.11 line that works today can stop working. Pin your built image, not the package list.

Step 5: Pin the base image by digest#

Docker's build advice: pin a digest to get the same image even if the publisher replaces the tag. The price, also in Docker's docs: you opt out of automatic security fixes.

Linux#

Run in terminalbash
docker buildx imagetools inspect gcr.io/distroless/static-debian13:nonroot
docker buildx imagetools inspect cgr.dev/chainguard/static:latest

Windows (PowerShell)#

Run in terminalpowershell
docker buildx imagetools inspect gcr.io/distroless/static-debian13:nonroot
docker buildx imagetools inspect cgr.dev/chainguard/static:latest

Mac (Terminal)#

Same commands as Linux.

Each prints Digest: sha256:.... Copy it behind the tag with an @. This is a dummy digest, replace it with yours:

File contentdockerfile
FROM gcr.io/distroless/static-debian13:nonroot@sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef AS final

Keep the tag too (it tells people what it is); Docker checks the digest. Do the same for the builder and the Chainguard lines.

Check it worked. docker build still works. Change one digit of the digest and it must fail.

Tip: After you pin, nothing announces updates. Dependabot (package-ecosystem: "docker") opens pull requests for tags and digests, and Diun can watch a base image through its file provider (we did not test that).

Step 6: Debug a container that has no shell#

Four ways in; use the lightest.

  1. Logs and settings. No shell needed:
Run in terminalbash
docker logs distroless-demo --tail 100
docker inspect distroless-demo
docker cp distroless-demo:/hello ./hello-copy
  1. A debug build. Our debug stage uses the debug-nonroot base, which adds a busybox shell (README).

Linux#

Run in terminalbash
cd ~/docker_volumes/distroless-demo
docker build --target debug -t distroless-demo:1.0.0-debug ./app
docker run -d --name demo-debug -p 127.0.0.1:8081:8080 distroless-demo:1.0.0-debug
docker exec -it demo-debug sh

Windows (PowerShell)#

Codepowershell
Set-Location "$HOME\docker_volumes\distroless-demo"
docker build --target debug -t distroless-demo:1.0.0-debug ./app
docker run -d --name demo-debug -p 127.0.0.1:8081:8080 distroless-demo:1.0.0-debug
docker exec -it demo-debug sh

Mac (Terminal)#

Same commands as Linux.

Type exit, then docker rm -f demo-debug. If a tag already has a suffix, put debug- in front (java21-debian13:debug-nonroot), as the README says.

  1. A sidecar. cdebug exec -it distroless-demo starts a helper container that shares the target's view, so the image stays untouched (command from the cdebug README; setup in our cdebug guide).
  2. Chainguard latest-dev. It has a shell and apk; Chainguard's docs show docker run -it --entrypoint /bin/sh cgr.dev/chainguard/php:latest-dev. static has no -dev tag, so use the sidecar.

Tip: debug is for a bench, not production: a shell in the final image is what you wanted to remove. Keep it a separate --target, as we did.

Step 7: Check what you built#

Linux#

Run in terminalbash
cd ~/docker_volumes/distroless-demo
docker run --rm -i hadolint/hadolint:v2.15.1 < app/Dockerfile
mkdir -p scan
docker save distroless-demo:1.0.0 -o scan/demo.tar
docker run --rm -v trivy-cache:/root/.cache -v "$PWD/scan":/work aquasec/trivy:0.77.0 image --input /work/demo.tar
grype docker-archive:./scan/demo.tar

Windows (PowerShell)#

Codepowershell
Set-Location "$HOME\docker_volumes\distroless-demo"
Get-Content .\app\Dockerfile | docker run --rm -i hadolint/hadolint:v2.15.1
New-Item -ItemType Directory -Force scan | Out-Null
docker save distroless-demo:1.0.0 -o scan\demo.tar
docker run --rm -v trivy-cache:/root/.cache -v "${PWD}\scan:/work" aquasec/trivy:0.77.0 image --input /work/demo.tar
grype docker-archive:.\scan\demo.tar

Mac (Terminal)#

Same commands as Linux.

  • Hadolint (guide) reads the Dockerfile and prints nothing or rule numbers such as DL3006.
  • Trivy (guide, pinned here to 0.77.0) and Grype (guide; install it first) list known vulnerabilities. Scan the Chainguard build too and compare. We did not run them, so we show no counts. Chainguard's docs say scanners do report findings in its images and the count depends on the build's age. Distrust "zero CVEs" from anyone.
  • Cosign (guide) checks who signed the base. Distroless is signed keylessly (README):
Run in terminalbash
cosign verify gcr.io/distroless/static-debian13:nonroot \
  --certificate-oidc-issuer https://accounts.google.com \
  --certificate-identity [email protected]

For a public Chainguard image the docs give the issuer https://token.actions.githubusercontent.com and the identity https://github.com/chainguard-images/images/.github/workflows/release.yaml@refs/heads/main.

Check it worked. Hadolint lists rules or nothing; the scanners print a table. Slim is a different route: it shrinks an existing fat image, while distroless and Wolfi start small.

Wolfi without Chainguard's images: apko in short#

Wolfi's packages are public (packages.wolfi.dev/os), and apko builds an image from a plain list. This is the official wolfi-base.yaml example from the apko repository, read 5 December 2026:

File contentyaml
contents:
  keyring:
    - https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
  repositories:
    - https://packages.wolfi.dev/os
  packages:
    - wolfi-base

cmd: /bin/sh -l

archs:
- x86_64
- aarch64

The apko README builds it with apko build config.yaml <tag> <output.tar> and loads it with docker load < output.tar. apko has no RUN: your own program must be packaged as an apk with melange. That is more than most homelabs need, and we did not test it. Never mix Alpine packages into Wolfi (the Wolfi README: unsupported, can create security problems).

Put it behind HTTPS (with or without Traefik)#

For a server with a domain: HTTPS at https://demo.example.com (a dummy name; use yours). Local-only users can skip this. You need a DNS record and ports 80 and 443. Create the shared network once (Windows: same line):

Run in terminalbash
docker network create proxy

With Traefik#

On a server that already runs Traefik v3, add labels and drop the host port. This assumes the proxy network, an entrypoint https and a resolver le; use your own names. Replace compose.yaml:

File contentyaml
services:
  hello:
    image: distroless-demo:1.0.0
    build:
      context: ./app
    container_name: distroless-demo
    restart: unless-stopped
    read_only: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=proxy"
      - "traefik.http.routers.hello.rule=Host(`demo.example.com`)"
      - "traefik.http.routers.hello.entrypoints=https"
      - "traefik.http.routers.hello.tls=true"
      - "traefik.http.routers.hello.tls.certresolver=le"
      - "traefik.http.services.hello.loadbalancer.server.port=8080"

networks:
  proxy:
    external: true

Then docker compose up -d. See our Traefik guide.

Check it worked. curl -I https://demo.example.com/ returns an HTTP status line over HTTPS with a valid certificate.

Without Traefik: Caddy#

No Traefik? Caddy gets and renews its own certificates: Let's Encrypt for a public domain, tls internal for a local one at home (Caddy guide).

Run in terminalbash
mkdir -p ~/docker_volumes/caddy/{conf,data,config}
cd ~/docker_volumes/caddy

Save as ~/docker_volumes/caddy/docker-compose.yml (caddy:2.11.9, newest release on 5 December 2026; we mount the conf folder, not the single file):

File contentyaml
services:
  caddy:
    image: caddy:2.11.9
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80/tcp"
      - "443:443/tcp"
      - "443:443/udp"
    volumes:
      - ./conf:/etc/caddy
      - ./data:/data
      - ./config:/config
    networks:
      - proxy

networks:
  proxy:
    external: true

Save as ~/docker_volumes/caddy/conf/Caddyfile. For a public domain:

File contenttext
demo.example.com {
    reverse_proxy distroless-demo:8080
}

For a home-only name add tls internal inside the block. In the demo's compose.yaml use the same networks: block as above and no ports:, then start both stacks with docker compose up -d.

Trust Caddy's root (home-only names, your own devices only). Linux (Debian and Ubuntu style):

Run in terminalbash
cd ~/docker_volumes/caddy
docker compose cp caddy:/data/caddy/pki/authorities/local/root.crt /tmp/caddy-root.crt
sudo cp /tmp/caddy-root.crt /usr/local/share/ca-certificates/caddy-local-root.crt
sudo update-ca-certificates

Windows (PowerShell as administrator):

Codepowershell
Set-Location "$HOME\docker_volumes\caddy"
docker compose cp caddy:/data/caddy/pki/authorities/local/root.crt "$env:TEMP\caddy-root.crt"
certutil -addstore -f "ROOT" "$env:TEMP\caddy-root.crt"

Mac (Terminal):

Run in terminalbash
cd ~/docker_volumes/caddy
docker compose cp caddy:/data/caddy/pki/authorities/local/root.crt /tmp/caddy-root.crt
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /tmp/caddy-root.crt

Check it worked. curl -I https://demo.example.com/ returns a status line over HTTPS; a home-only name shows a padlock once the root is trusted.

Security and testing#

ControlHow
No shell, no package managerAn intruder cannot run apk add or sh. The point of this guide
Non-root:nonroot for distroless; Chainguard static already runs as 65532
Read-only, no extra rightsread_only, cap_drop: [ALL], no-new-privileges. If the app must write, use a tmpfs: for /tmp or a volume
Loopback port127.0.0.1:8080:8080: only this machine or a proxy on it
Secrets.env with chmod 600 or Docker secrets, never in the Dockerfile: image layers can be read back
ProvenanceVerify with Cosign; pin by digest; never deploy debug

Quick tests:

Run in terminalbash
cd ~/docker_volumes/distroless-demo
docker compose ps
docker inspect --format '{{.State.Health.Status}}' distroless-demo
docker inspect --format '{{.Config.User}}' distroless-demo
curl -s http://127.0.0.1:8080/healthz

The user line should print 65532. Windows: curl.exe, same docker lines.

Common mistakes#

MistakeWhy it happensDo this instead
Shell-form HEALTHCHECK, CMD or ENTRYPOINT: exec: "/bin/sh": stat /bin/sh: no such file or directory: unknown (183, 62)Shell form runs /bin/sh -c ..., and there is no /bin/shArray form, and a probe inside your own program
RUN mkdir ... in the final stage: OCI runtime create failed: ... exec: "/bin/sh": stat /bin/sh: no such file or directory (419)RUN also needs /bin/sh, even on :debug (there it is /busybox/sh)Do it in the build stage and COPY the result
docker exec -it <name> /bin/sh: OCI runtime exec failed: ... stat /bin/sh: no such file or directory (891)There is no shell to startStep 6
Build on a newer glibc than the base: version 'GLIBC_2.32' not found (required by /app) (1342, 390)Builder newer than the runtime's C libraryCGO_ENABLED=0 with static, or a builder of the same Debian generation
A cgo or dynamic program on static; "file not found" although it exists (58 asked for this to be documented; no exact text there)The loader and libraries are missingCGO_ENABLED=0, or base or cc
A Python venv copied from python:3.x: sh: /venv/bin/python: not found (1543); No module named <dependency> or SyntaxError: Non-UTF-8 code starting with '\x80' in file /usr/bin/python3 (1960, open)The venv points to /usr/local/bin/python; distroless Python is /usr/bin/python, and the minor version must matchThe python3 README: build on python:3.13-slim-trixie for python3-debian13, add a symlink
Asking for cgr.dev/chainguard/python:3.12: MANIFEST_UNKNOWNFree images are latest and latest-dev onlylatest plus a digest, or Starter and Team
Pinning a digest and never updating itA digest never moves, so it never gets fixesA watcher or reminder (Step 5), rebuild on purpose
Shipping a debug imageEasier than fixing the real problemKeep debug a local --target
Alpine apk packages in WolfiBoth use apkUnsupported (Wolfi README); use Wolfi packages or melange
AI assistants: -debian11 or -debian12 tags, no suffix, RUN apt-get or adduser in the final stage, shell-form ENTRYPOINT, static for a cgo appOlder articles; the README now lists -debian13 only-debian13, array form, all setup in the build stage; nonroot already exists
AI assistants: pinned Chainguard tags like python:3.12, or "zero CVEs"Marketing pages from before the free-tier limitsFree means latest; scan your own build

Tip: The -debian12 tags still exist in the registry, but the newest static-debian12 build we saw was from 21 August 2026, while -debian13 was rebuilt in November. An old tag is not an updated tag.

Tip: Before you copy a tag from a blog or a chat answer, run docker buildx imagetools inspect <image:tag>. "Not found" means the source is out of date.

Troubleshooting#

ProblemSolution
Container restarts at oncedocker logs distroless-demo --tail 100; a missing library shows as a "not found" line
Health stays starting or turns unhealthyCheck the probe port, docker inspect distroless-demo, and that the probe is in array form
permission denied writing a filenonroot cannot write to root-owned folders. Mount a volume owned by 65532, or use a tmpfs: for /tmp
Wrong CPU architectureBoth static images have amd64 and arm64; use docker buildx build --platform for another machine
Cannot pull cgr.dev/chainguard/...Try docker pull cgr.dev/chainguard/static:latest by hand; status page: status.cgr.dev
Need to look inside the basedocker run --rm -it --entrypoint=sh gcr.io/distroless/static-debian13:debug-nonroot (README form)

Exact error texts#

  • standard_init_linux.go:211: exec user process caused "exec format error" (issue 657): reported for old debug images on arm64, closed February 2022. Do not pin an ancient digest.
  • chdir to cwd ("/home/nonroot") set in config.json failed: permission denied (issue 718): runc v1.0.0-rc93, 2021; fixed in the runtime. Update Docker.
  • exec: "sh": executable file not found in $PATH: unknown (Chainguard's debugging docs): no shell, as designed.

Known bugs (December 2026)#

Distroless 1960 (open since January 2026) is the Python mismatch above; 1703 asks for more Python minor versions. We saw nothing that stops the steps in this guide.

Updates and backups#

Update by rebuilding:

Run in terminalbash
cd ~/docker_volumes/distroless-demo
docker buildx imagetools inspect gcr.io/distroless/static-debian13:nonroot
# put the new digest in app/Dockerfile, then:
docker compose build --pull
docker compose up -d
docker image prune -f

Windows: same lines. Bump your image tag (1.0.1) so you can roll back.

What to back up. The app folder and compose.yaml (with the pinned digests). Images can be rebuilt; the demo has no data.

Linux and Mac#

Save as ~/docker_volumes/distroless-demo/backup.sh:

File contentbash
#!/usr/bin/env bash
set -euo pipefail
base="$HOME/docker_volumes/distroless-demo"
out="$base/backups/distroless-demo-$(date +%F).tar.gz"
tar -czf "$out" -C "$base" app compose.yaml
chmod 600 "$out"

Run chmod 700 on it, then add with crontab -e (on a Mac write /Users/<your-user>/...):

File contenttext
0 3 * * * /home/<your-user>/docker_volumes/distroless-demo/backup.sh

Windows (PowerShell)#

Save as $HOME\docker_volumes\distroless-demo\backup.ps1:

Codepowershell
$base = "$HOME\docker_volumes\distroless-demo"
$out = "$base\backups\distroless-demo-$(Get-Date -Format yyyy-MM-dd).tar.gz"
tar.exe -czf $out -C $base app compose.yaml

In Task Scheduler run powershell.exe -NoProfile -File <full-path-to-the-script> daily at 03:00.

Restore test#

Unpack in an empty folder and rebuild:

Run in terminalbash
tar -xzf distroless-demo-<date>.tar.gz
docker compose build
docker compose up -d
curl -s http://127.0.0.1:8080/

You should see the same hello line; with a pinned digest the base is the same one.

Performance and resources#

We measured nothing on a running machine. The compressed download sizes are in the table at the top; static debug-nonroot is 1.53 MiB. The README says about 2 MiB for static, unpacked. Your image is the base plus your binary. Build time is mostly downloading the builder; docker stats distroless-demo shows memory of the running app.

FAQ#

Is distroless the same as Alpine? No. Alpine is a small distribution with a shell and apk. Distroless has neither and uses Debian's glibc.

Can I install a package into a distroless image? Not with RUN. Install in the build stage and copy the files, or build the image another way (Chainguard has a page on installing apks into distroless variants).

Do I need Chainguard to use Wolfi? No. The packages and the apko and melange tools are open source. Chainguard's hardened images are the product on top; only some are free.

Why not FROM scratch? For a static Go binary you can. Distroless static adds CA certificates, timezone data and a non-root user entry.

Will a scanner say my image has no vulnerabilities? Not always. Your own program is scanned too, and new findings appear with time. Rebuild often.

Sources#

Checked against the official docs on 2026-12-05. Nothing was run on a real machine by DIY Lab Hub; the commands come from the docs and the issues above, and the image facts from the public registry APIs.

Try one of these