Docker's slogan is "Build, Ship And Run Any App Anywhere," but in the last couple of years the "build" part seems to have stagnated. That all changed with the release of buildkit, which is now part of Docker 19.03. In this talk Adrian Mouat, Chief Scientist at Container Solutions, will take a look at the new tooling and how it can be used to improve the development build cycle.
YouTube: https://youtu.be/9nRKgf3JMCo
Speaker: Adrian Mouat, Chief Scientist, Container Solutions
Bio: Adrian has been involved with containers from the early days of Docker and authored the O'Reilly book "Using Docker" (https://atlas.oreilly.com/oreillymedia/using-docker). He is currently Chief Scientist at Container Solutions, a pan-european company focusing on consulting and product development for microservices and containers.
Host: Tamao Nakahara, Head of Developer Experience, Weaveworks
To learn more about GitOps, check out: The Practical Guide to GitOps (eBook): http://bit.ly/gitops_guide
8. Enter BuildKit
â Fundamental rewrite of backend
â Still client server model
â (but see img by Jessie Frazelle)
â Intermediate representation
â LLB
@adrianmouat
9. Low Level Builder (LLB)
â Intermediate format for compiler
â DockerïŹles etc are really code
â Similar idea to LLVM IR
â Also Java bytecode, .NET CIL
â Forms a Graph (DAG)
@adrianmouat
10. Simple Chain
FROM debian:jessie
RUN apt-get update
RUN apt-get install -y cowsay fortune
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
@adrianmouat
18. Mount Options
â Weâve seen cache. Also
â bind
â Volume from build context, read-only
â tmpfs
â In-memory
@adrianmouat
19. Mount Options
â secret and ssh
â Allow sensitive date to be used but not leaked in ïŹnal
image
â Requires build arguments as well DockerïŹle changes
@adrianmouat
20. secret Example
# syntax = docker/dockerfile:experimental
FROM python:3
RUN pip install awscli
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials aws
s3 cp s3://... ...
â docker build --secret id=aws,src=$HOME/.aws/credentials
-t my/image .
@adrianmouat
21. More cache
â --cache-from
â Load cache from existing image!
https://asciinema.org/a/bZrOoCDK6oChNYfYD8QlY8crB
@adrianmouat
22. buildx
â Buildx is an experimental plugin for Docker
â EïŹectively separate binary
â Standalone buildkit
â Can talk to multiple builder instances
â Instances can be Docker or buildkit
â Also some new commands
@adrianmouat
23. buildx
$ docker buildx --help
Usage: docker buildx COMMAND
Build with BuildKit
Management Commands:
imagetools Commands to work on images in registry
Commands:
bake Build from a file
build Start a build
create Create a new builder instance
inspect Inspect current builder instance
ls List builder instances
rm Remove a builder instance
stop Stop builder instance
use Set the current builder instance
version Show buildx version information
@adrianmouat
25. So distributed builds?
â Not quite
â Instances support diïŹerent platforms
â diïŹerent builders for arm etc
â But not one build across multiple instances :(
@adrianmouat
26. Multiplatform Builds
â docker build --platform=linux/arm64 .
â Works, assuming your base images support
arm64 etc
â By default, uses QEMU under the hood
â Can list multiple platforms
â Or use buildx instances for given platformsâŠ
â Can also use language tooling!
@adrianmouat
27. Concurrent Builds
â Exploit parallelism in LLB DAG
â With DockerïŹle, can use multistage builds
â True parallelism requires more intelligent front
ends
@adrianmouat
28. Bake
â Personally, I hate Make
â But shell scripts and MakeïŹles are common
with Docker
â Calling docker build from Make usually
sequential
31. Conclusion
â Way we deploy and run software has changed
â Microservices
â Kubernetes
â Service Mesh
â Observability
@adrianmouat
32. Conclusion
â Way we develop and build has changed
â But further to go
â Container Native?
â LLB frontends, IDE integration
â Cluster Native?
â Tilt, SkaïŹold, Draft
â Darklang
@adrianmouat
33. References
â DockerCon presentation on buildkit internals and frontends by Tonis
Tiigi and Matt Rickard
â https://www.youtube.com/watch?v=x5zDN9_c-k4
â https://docs.google.com/presentation/d/1maienHIl8FtCmTcx8QFb_i
eM9ElDoOY1HrX8YnsxvRQ/
â MockerïŹle blog
https://matt-rickard.com/building-a-new-dockerfile-frontend/
â Buildkit https://github.com/moby/buildkit/
â Solver design https://github.com/moby/buildkit/blob/master/docs/solver.md
@adrianmouat