Dockerfile: the best practices
summary
Starts from a 1.7 GB monolithic image that takes ~8 minutes to build and shows how to split it into separate images (MongoDB official image, Nginx proxy, Node-built React static site, Spring Boot jar) to reach ~700 MB total, faster pulls and smaller pushes. Uses multi-stage builds, copies package.json/package-lock before source to cache installs, cleans apt caches and unnecessary layers, switches from JDK to JRE, wires services with Compose and networks, and enforces avoid running as root and use official images and single service per container.
AI-written summary · about
chapters (6)
related talks
30mDockerfile - Best Practices
41mDocker Best-Practice and Dockerfile Optimization
43mContainer images anti-patterns
46mDockerfiles, Buildpacks, Jib and more, best way to run Java code in Containers?
27mDocker Image Journey - How to Shrink a Docker Image
14mSmall Containers? or Small Images?
46mWrite Once, Run Anywhere? Building Perfect Docker Images for Java Apps
01h 00mDocker, FROM scratch
