Lab: Building Container Images


目录

Take a working but naïve Dockerfile and progressively improve it into a production-grade image. Each section introduces one technique, applied to a real Python Flask app, so you can see the impact directly.

Launch the lab

{{< labspace-launch image="dockersamples/labspace-building-images" >}}

What you'll learn

By the end of this Labspace, you will have completed the following:

Modules

# Module Description
1 Welcome & Your First Build Explore the sample app and build the initial image
2 Understanding Image Layers Inspect layers with docker history and see the layer cleanup pitfall
3 Dockerfile Best Practices Fix cache ordering, add .dockerignore, and switch to a non-root user
4 Multi-Stage Builds Run tests as a build gate and use a slim base for the production stage
5 Choosing a Base Image Compare slim, Alpine, and Docker Hardened Images
6 Build Secrets Show why ARG leaks secrets and use --mount=type=secret safely
7 Wrap-up Review the complete best-practices checklist and next steps

版本号 #2
由 壳壳虫 创建于 2026-10-31 18:46:21 UTC
由 壳壳虫 更新于 2026-10-31 18:46:22 UTC