This is a list of recurring anti-patterns that I see when I help folks with their container build pipelines, and suggestions to avoid them or refactor them into something better. By Jérôme Petazzoni.
Many of them are harmless when used separately. But when combined, they can easily compromise your productivity and waste time and resources, as we will see.
The guide then covers the following in depth:
- Big images
- All-in-one mega images
- Data sets
- Small images
- Rebuilding common bases
- Building from the root of a giant monorepo
- Not using BuildKit
- Requiring rebuilds for every single change
- Using custom scripts instead of existing tools
- Forcing things to run in containers
- Using overly complex tools
- Conflicting names for scripts and images
- Building with Dockerfiles
BuildKit is a new backend for docker build. It’s a complete rehaul with a ton of new features, including parallel builds, cross-arch builds (e.g. building ARM images on Intel and vice versa), building images in Kubernetes Pods, and much more; while remaining fully compatible with the existing Dockerfile syntax. It’s like switching to a fully electric car: we still drive it with a wheel and two pedals, but internally it is completely different from the old thing.
And final note: don’t treat these recommendations as absolute rules. What author is saying is “hey, careful, if you do this, it can have unexpected consequences; look, here is what I suggest to improve the situation”. Nice one!
[Read More]