Tags: #docker #dockerfile #goodpractice #dockerbuild
Last Reviewed: 29/08/2024
Incremental Build Time:
COPY .
and instead specify only the necessary files to prevent unnecessary cache busts.apt-get update
and package installations in one RUN
instruction to ensure they are treated as a single cacheable unit.Image Size:
RUN
instruction that installs packages to prevent it from increasing the image size.Maintainability:
latest
tag; instead, use more specific tags to prevent breaking changes.slim
or alpine
) to further reduce the image size while being cautious of compatibility issues.Reproducibility:
Multi-Stage Builds:
FROM
statements to separate the build environment from the final runtime environment. This technique allows you to include only the necessary runtime dependencies in the final image, resulting in a smaller, more efficient image.