Speeding up Your Docker Image Build
summary
Five concrete tactics: avoid rebuilds when possible, reorder Dockerfile into an inverted pyramid so big slow layers stay low, and copy only requirements.txt before pip install to keep cache hits. Reduce downloads with apt --no-install-recommends and split dev deps, then enable BuildKit with DOCKER_BUILDKIT=1 and use --mount=type=cache for pip/apt caches. Demonstrations show cache mounts and commands and report converting 10–15 minute rebuilds into minute-scale iterations.
AI-written summary · about
chapters (15)
- 0:00Speeding up Your Docker Image Build
- 1:48My goal: to help you reclaim days of your time.
- 3:20Context switching. Busy waiting. Slow feedback loops.
- 3:515 tips to speed up your Docker image builds!
- 4:16You don't have to use Docker everywhere.
- 4:38First step towards automation Executable documentation
- 6:22Structure your Dockerfile instructions like an inverted pyramid.
- 6:41Docker image layers are friends! They can be cached and reused.
- 8:23Only copy files which are needed for the next step.
- 8:36Dockerfile snippet
- 10:00We're reusing layers... But downloading packages takes a while.
- 10:27Download less stuff.
- 11:36Use BuildKit with the new cache mount feature.
- 14:15You can (and should) measure where your bottlenecks are.
- 17:59Soon: CPU & memory are the new bottleneck...
related talks
15mOptimizing Cache Usage in Docker Builds
05m3 Weird Tricks to Make Docker Builds Go Vroom
29mHow to Improve Your Image Builds Using Advance Docker Build
58mOptions Galore to Get from Source Code to Container
41mDocker Best-Practice and Dockerfile Optimization
36mPractical Tips for Build Optimization for GitLab and Docker Users
54mHowto: Options Galore to Get from Source Code to Container
50mHowto: Options Galore to Get from Source Code to Container
