Stop memorizing boilerplate Dockerfiles. Here is a complete 101-lesson curriculum taking you from Linux kernel primitives and namespaces all the way to custom OCI runtimes and production network packet tracing.
# Multi-stage pattern: compiling a static binary and copying into distroless/scratch FROM golang:1.23-alpine AS builder WORKDIR /src COPY go.mod go.sum ./ RUN --mount=type=cache,target=/go/pkg/mod \ go mod download COPY . . RUN CGO_ENABLED = 0 GOOS = linux go build -ldflags= "-s -w" -o /app/server ./cmd/server
FROM gcr.io/distroless/static-debian12:nonroot COPY --from=builder /app/server /server USER nonroot:nonroot ENTRYPOINT [ "/server" ]
Enter fullscreen mode
Exit fullscreen mode
Most Docker tutorials teach you just enough to get into trouble.…