Need to package an app without installing its runtime on your machine? Start the Dockerfile with `FROM` and an existing image. That base image supplies the starting layers; later instructions add your application. Images built from the same base can share its stored layers, so the sizes shown by `docker image ls` should not simply be added together to estimate disk use. section 3.4 section 4.2
Choose a base for the job each build stage performs:
- For a build stage, use an image with the compiler or packaging tools. For the final stage, use one with what the app needs to run. A Go build can use `diamol/golang:2e` for its tools and `diamol/base:2e` for the compiled server. section 4.4
- Prefer the smallest compatible runtime and OS variant, then test the app. Extra tools increase image size and can give an attacker more to use if the container is compromised. A JRE may be a better fit than a JDK for a Java app that only needs to run. section 17.2
- For Windows apps, choose an image that supplies the needed dependencies without unnecessary ones. An installation stage can use Windows Server Core, then copy the installed output into a Nano Server stage; test the Windows version you select. section 13.2
- If you may need more platforms later, start with a multi-platform base image and avoid OS-specific `RUN` and `CMD` instructions. section 12.5
Build with tools; run without them
A two-stage Go Dockerfile begins with `FROM diamol/golang:2e AS builder`, compiles the server, then starts a second stage with `FROM diamol/base:2e`. `COPY --from=builder /server .` brings the binary into the application image. Build it with `docker image build -t image-gallery .`; compare image sizes with `docker image ls`. The example application image is 35.1 MB, compared with 230 MB for the Go toolset image. section 4.4
Base-image choice is an ongoing optimization, not a one-time size contest. Check compatibility before adopting a smaller variant, and monitor build and push/pull times as images change. Teams can maintain a curated set of base images for repeated use. section 17.2 section 17.5






