Junior · Docker and Kubernetes
Build an image, not a development machine
What belongs in a production Go container image?
Try explaining this aloud before opening the answer. State your assumptions and trace a boundary case.
Reveal a strong answer
Use a build stage with the compiler and verified dependencies, then copy only the runtime artifact and required assets into a smaller runtime stage. Pin base images/dependencies according to the release policy and avoid secrets in layers.
A static pure-Go binary may fit a minimal image, but cgo, CA roots, timezone data and native libraries change requirements. A scratch image does not magically supply certificates or a shell.
Run as a non-root user when feasible, keep writable locations explicit, and handle signals in the actual application process. Rebuild for supported platforms and scan the final artifact, not only the builder.
Common trap
A successful build on macOS does not prove the binary or its native dependencies run in Linux.
Try it
HTTPS calls fail only in a scratch container. What is missing besides the Go executable?
Worked solution
Check CA trust roots, DNS/network configuration and the exact TLS error. Supply required certificates in the runtime image. Do not “fix” this by disabling TLS verification.
Change the constraint
What changes when CGO_ENABLED=1 links a dynamic library?
How did you do?
Self-assessment, not a compiler pass or interview score. Explain the reasoning unaided before marking understood.
Not marked. Progress stays on this browser, separate from course completion.
Primary references
Checked 2026-10-20. Use documentation for your pinned runtime, driver and tool version.