SlideShare ist ein Scribd-Unternehmen logo
1 von 33
info@container-solutions.com
www.container-solutions.com
Photo by Kevin Wood
Advanced
Techniques for
Building
Container
Images
Adrian Mouat
@adrianmouat
Docker
■ Build, Ship, Run
■ Build overshadowed
by orchestration
■ Recent focus on
deployment not
development @adrianmouat
Container Native
Development
Using docker build instead of locally
installed language tooling
@adrianmouat
Python Dev with Docker
■ Replace virtualenv
■ Use volumes for live
development
■ Portable
■ Reproducible
Go Dev with Docker
■ Still advantages
○ No installation
○ Consistent env
○ Easy for end users
■ But a killer disadvantage...
@adrianmouat
Photo by JĂŒrgen Schoner
Docker Build Problems
■ Slower than local compilation
■ Simplistic caching
■ Requires root
■ Secrets
■ DockerïŹle stopped evolving
@adrianmouat
Enter BuildKit
■ Fundamental rewrite of backend
■ Still client server model
○ (but see img by Jessie Frazelle)
■ Intermediate representation
○ LLB
@adrianmouat
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
Simple Chain
FROM debian:jessie
RUN apt-get update
RUN apt-get install -y cowsay fortune
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
@adrianmouat
Graph
@adrianmouat
Frontends
■ Source that compiles to LLB
■ New dockerïŹle frontend
■ Handful of others
■ Essential to exploit parallelism
@adrianmouat
Other Highlights
■ New mount options
■ Output formats
■ Distributable workers
■ Cross-compilation
■ Rootless execution
■ bake @adrianmouat
Dev Speed Contest
■ go build vs docker build
■ Runc project
@adrianmouat
Close Enough?
■ Maybe
■ DeïŹnitely for occasional bug ïŹxes
■ Maybe not for full-time
@adrianmouat
IDEs
■ Incremental compilation
■ Could IDEs use containers?
○ Team gets same settings and libs
@adrianmouat
Other New StuïŹ€
Mount Options
■ We’ve seen cache. Also
○ bind
■ Volume from build context, read-only
○ tmpfs
■ In-memory
@adrianmouat
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
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
More cache
■ --cache-from
○ Load cache from existing image!
https://asciinema.org/a/bZrOoCDK6oChNYfYD8QlY8crB
@adrianmouat
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
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
buildx
$ docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS
second-build docker-container
second-build0 unix:///var/run/docker.sock inactive
default * docker
default default running linux/amd64,
linux/arm64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7,
linux/arm/v6
...
@adrianmouat
So distributed builds?
■ Not quite
■ Instances support diïŹ€erent platforms
○ diïŹ€erent builders for arm etc
■ But not one build across multiple instances :(
@adrianmouat
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
Concurrent Builds
■ Exploit parallelism in LLB DAG
■ With DockerïŹle, can use multistage builds
■ True parallelism requires more intelligent front
ends
@adrianmouat
Bake
■ Personally, I hate Make
■ But shell scripts and MakeïŹles are common
with Docker
■ Calling docker build from Make usually
sequential
Enter Bake
group “default” {
targets = [“db”, “webapp-dev”] }
target “webapp-dev” {
dockerfile = "Dockerfile.webapp"
tags = ["docker.io/username/webapp"] }
target “webapp-release” {
inherits = [“webapp-dev”]
platforms = [“linux/amd64”, “linux/arm64”]
}
@adrianmouat
Bake
■ docker buildx bake
■ docker buildx bake release
■ docker buildx bake test validate lint
■ docker buildx bake binaries-cross
■ docker buildx bake help
@adrianmouat
Conclusion
■ Way we deploy and run software has changed
○ Microservices
○ Kubernetes
○ Service Mesh
○ Observability
@adrianmouat
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
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

Weitere Àhnliche Inhalte

Mehr von Weaveworks

How to Avoid Kubernetes Multi-tenancy Catastrophes
How to Avoid Kubernetes Multi-tenancy CatastrophesHow to Avoid Kubernetes Multi-tenancy Catastrophes
How to Avoid Kubernetes Multi-tenancy CatastrophesWeaveworks
 
Building internal developer platform with EKS and GitOps
Building internal developer platform with EKS and GitOpsBuilding internal developer platform with EKS and GitOps
Building internal developer platform with EKS and GitOpsWeaveworks
 
GitOps Testing in Kubernetes with Flux and Testkube.pdf
GitOps Testing in Kubernetes with Flux and Testkube.pdfGitOps Testing in Kubernetes with Flux and Testkube.pdf
GitOps Testing in Kubernetes with Flux and Testkube.pdfWeaveworks
 
Intro to GitOps with Weave GitOps, Flagger and Linkerd
Intro to GitOps with Weave GitOps, Flagger and LinkerdIntro to GitOps with Weave GitOps, Flagger and Linkerd
Intro to GitOps with Weave GitOps, Flagger and LinkerdWeaveworks
 
Implementing Flux for Scale with Soft Multi-tenancy
Implementing Flux for Scale with Soft Multi-tenancyImplementing Flux for Scale with Soft Multi-tenancy
Implementing Flux for Scale with Soft Multi-tenancyWeaveworks
 
Accelerating Hybrid Multistage Delivery with Weave GitOps on EKS
Accelerating Hybrid Multistage Delivery with Weave GitOps on EKSAccelerating Hybrid Multistage Delivery with Weave GitOps on EKS
Accelerating Hybrid Multistage Delivery with Weave GitOps on EKSWeaveworks
 
The Story of Flux Reaching Graduation in the CNCF
The Story of Flux Reaching Graduation in the CNCFThe Story of Flux Reaching Graduation in the CNCF
The Story of Flux Reaching Graduation in the CNCFWeaveworks
 
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...Weaveworks
 
Securing Your App Deployments with Tunnels, OIDC, RBAC, and Progressive Deliv...
Securing Your App Deployments with Tunnels, OIDC, RBAC, and Progressive Deliv...Securing Your App Deployments with Tunnels, OIDC, RBAC, and Progressive Deliv...
Securing Your App Deployments with Tunnels, OIDC, RBAC, and Progressive Deliv...Weaveworks
 
Flux’s Security & Scalability with OCI & Helm Slides.pdf
Flux’s Security & Scalability with OCI & Helm Slides.pdfFlux’s Security & Scalability with OCI & Helm Slides.pdf
Flux’s Security & Scalability with OCI & Helm Slides.pdfWeaveworks
 
Flux Security & Scalability using VS Code GitOps Extension
Flux Security & Scalability using VS Code GitOps Extension Flux Security & Scalability using VS Code GitOps Extension
Flux Security & Scalability using VS Code GitOps Extension Weaveworks
 
Deploying Stateful Applications Securely & Confidently with Ondat & Weave GitOps
Deploying Stateful Applications Securely & Confidently with Ondat & Weave GitOpsDeploying Stateful Applications Securely & Confidently with Ondat & Weave GitOps
Deploying Stateful Applications Securely & Confidently with Ondat & Weave GitOpsWeaveworks
 
Robust Network Security and Observability with GitOps and Cilium
Robust Network Security and Observability with GitOps and CiliumRobust Network Security and Observability with GitOps and Cilium
Robust Network Security and Observability with GitOps and CiliumWeaveworks
 
Intro to GitOps & Flux.pdf
Intro to GitOps & Flux.pdfIntro to GitOps & Flux.pdf
Intro to GitOps & Flux.pdfWeaveworks
 
Simplifying Hybrid Kubernetes with Weaveworks and EKS.pdf
Simplifying Hybrid Kubernetes with Weaveworks and EKS.pdfSimplifying Hybrid Kubernetes with Weaveworks and EKS.pdf
Simplifying Hybrid Kubernetes with Weaveworks and EKS.pdfWeaveworks
 
Weave GitOps 2022.09 Release: A Fast & Reliable Path to Production with Progr...
Weave GitOps 2022.09 Release: A Fast & Reliable Path to Production with Progr...Weave GitOps 2022.09 Release: A Fast & Reliable Path to Production with Progr...
Weave GitOps 2022.09 Release: A Fast & Reliable Path to Production with Progr...Weaveworks
 
Building a Security First Approach Across Hybrid Cloud with GitOps and Policy...
Building a Security First Approach Across Hybrid Cloud with GitOps and Policy...Building a Security First Approach Across Hybrid Cloud with GitOps and Policy...
Building a Security First Approach Across Hybrid Cloud with GitOps and Policy...Weaveworks
 
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...Weaveworks
 
DevOps Automation with GitOps: Consistent and Secure End to End Deployments
DevOps Automation with GitOps: Consistent and Secure End to End DeploymentsDevOps Automation with GitOps: Consistent and Secure End to End Deployments
DevOps Automation with GitOps: Consistent and Secure End to End DeploymentsWeaveworks
 
Trusted Application Delivery: Achieving Ultimate Security
Trusted Application Delivery: Achieving Ultimate SecurityTrusted Application Delivery: Achieving Ultimate Security
Trusted Application Delivery: Achieving Ultimate SecurityWeaveworks
 

Mehr von Weaveworks (20)

How to Avoid Kubernetes Multi-tenancy Catastrophes
How to Avoid Kubernetes Multi-tenancy CatastrophesHow to Avoid Kubernetes Multi-tenancy Catastrophes
How to Avoid Kubernetes Multi-tenancy Catastrophes
 
Building internal developer platform with EKS and GitOps
Building internal developer platform with EKS and GitOpsBuilding internal developer platform with EKS and GitOps
Building internal developer platform with EKS and GitOps
 
GitOps Testing in Kubernetes with Flux and Testkube.pdf
GitOps Testing in Kubernetes with Flux and Testkube.pdfGitOps Testing in Kubernetes with Flux and Testkube.pdf
GitOps Testing in Kubernetes with Flux and Testkube.pdf
 
Intro to GitOps with Weave GitOps, Flagger and Linkerd
Intro to GitOps with Weave GitOps, Flagger and LinkerdIntro to GitOps with Weave GitOps, Flagger and Linkerd
Intro to GitOps with Weave GitOps, Flagger and Linkerd
 
Implementing Flux for Scale with Soft Multi-tenancy
Implementing Flux for Scale with Soft Multi-tenancyImplementing Flux for Scale with Soft Multi-tenancy
Implementing Flux for Scale with Soft Multi-tenancy
 
Accelerating Hybrid Multistage Delivery with Weave GitOps on EKS
Accelerating Hybrid Multistage Delivery with Weave GitOps on EKSAccelerating Hybrid Multistage Delivery with Weave GitOps on EKS
Accelerating Hybrid Multistage Delivery with Weave GitOps on EKS
 
The Story of Flux Reaching Graduation in the CNCF
The Story of Flux Reaching Graduation in the CNCFThe Story of Flux Reaching Graduation in the CNCF
The Story of Flux Reaching Graduation in the CNCF
 
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
 
Securing Your App Deployments with Tunnels, OIDC, RBAC, and Progressive Deliv...
Securing Your App Deployments with Tunnels, OIDC, RBAC, and Progressive Deliv...Securing Your App Deployments with Tunnels, OIDC, RBAC, and Progressive Deliv...
Securing Your App Deployments with Tunnels, OIDC, RBAC, and Progressive Deliv...
 
Flux’s Security & Scalability with OCI & Helm Slides.pdf
Flux’s Security & Scalability with OCI & Helm Slides.pdfFlux’s Security & Scalability with OCI & Helm Slides.pdf
Flux’s Security & Scalability with OCI & Helm Slides.pdf
 
Flux Security & Scalability using VS Code GitOps Extension
Flux Security & Scalability using VS Code GitOps Extension Flux Security & Scalability using VS Code GitOps Extension
Flux Security & Scalability using VS Code GitOps Extension
 
Deploying Stateful Applications Securely & Confidently with Ondat & Weave GitOps
Deploying Stateful Applications Securely & Confidently with Ondat & Weave GitOpsDeploying Stateful Applications Securely & Confidently with Ondat & Weave GitOps
Deploying Stateful Applications Securely & Confidently with Ondat & Weave GitOps
 
Robust Network Security and Observability with GitOps and Cilium
Robust Network Security and Observability with GitOps and CiliumRobust Network Security and Observability with GitOps and Cilium
Robust Network Security and Observability with GitOps and Cilium
 
Intro to GitOps & Flux.pdf
Intro to GitOps & Flux.pdfIntro to GitOps & Flux.pdf
Intro to GitOps & Flux.pdf
 
Simplifying Hybrid Kubernetes with Weaveworks and EKS.pdf
Simplifying Hybrid Kubernetes with Weaveworks and EKS.pdfSimplifying Hybrid Kubernetes with Weaveworks and EKS.pdf
Simplifying Hybrid Kubernetes with Weaveworks and EKS.pdf
 
Weave GitOps 2022.09 Release: A Fast & Reliable Path to Production with Progr...
Weave GitOps 2022.09 Release: A Fast & Reliable Path to Production with Progr...Weave GitOps 2022.09 Release: A Fast & Reliable Path to Production with Progr...
Weave GitOps 2022.09 Release: A Fast & Reliable Path to Production with Progr...
 
Building a Security First Approach Across Hybrid Cloud with GitOps and Policy...
Building a Security First Approach Across Hybrid Cloud with GitOps and Policy...Building a Security First Approach Across Hybrid Cloud with GitOps and Policy...
Building a Security First Approach Across Hybrid Cloud with GitOps and Policy...
 
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
Security & Resiliency of Cloud Native Apps with Weave GitOps & Tetrate Servic...
 
DevOps Automation with GitOps: Consistent and Secure End to End Deployments
DevOps Automation with GitOps: Consistent and Secure End to End DeploymentsDevOps Automation with GitOps: Consistent and Secure End to End Deployments
DevOps Automation with GitOps: Consistent and Secure End to End Deployments
 
Trusted Application Delivery: Achieving Ultimate Security
Trusted Application Delivery: Achieving Ultimate SecurityTrusted Application Delivery: Achieving Ultimate Security
Trusted Application Delivery: Achieving Ultimate Security
 

KĂŒrzlich hochgeladen

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

KĂŒrzlich hochgeladen (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Advanced build techniques for container images with Adrian Mouat

  • 1. info@container-solutions.com www.container-solutions.com Photo by Kevin Wood Advanced Techniques for Building Container Images Adrian Mouat @adrianmouat
  • 2. Docker ■ Build, Ship, Run ■ Build overshadowed by orchestration ■ Recent focus on deployment not development @adrianmouat
  • 3. Container Native Development Using docker build instead of locally installed language tooling @adrianmouat
  • 4. Python Dev with Docker ■ Replace virtualenv ■ Use volumes for live development ■ Portable ■ Reproducible
  • 5. Go Dev with Docker ■ Still advantages ○ No installation ○ Consistent env ○ Easy for end users ■ But a killer disadvantage... @adrianmouat
  • 7. Docker Build Problems ■ Slower than local compilation ■ Simplistic caching ■ Requires root ■ Secrets ■ DockerïŹle stopped evolving @adrianmouat
  • 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
  • 12. Frontends ■ Source that compiles to LLB ■ New dockerïŹle frontend ■ Handful of others ■ Essential to exploit parallelism @adrianmouat
  • 13. Other Highlights ■ New mount options ■ Output formats ■ Distributable workers ■ Cross-compilation ■ Rootless execution ■ bake @adrianmouat
  • 14. Dev Speed Contest ■ go build vs docker build ■ Runc project @adrianmouat
  • 15. Close Enough? ■ Maybe ■ DeïŹnitely for occasional bug ïŹxes ■ Maybe not for full-time @adrianmouat
  • 16. IDEs ■ Incremental compilation ■ Could IDEs use containers? ○ Team gets same settings and libs @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
  • 24. buildx $ docker buildx ls NAME/NODE DRIVER/ENDPOINT STATUS PLATFORMS second-build docker-container second-build0 unix:///var/run/docker.sock inactive default * docker default default running linux/amd64, linux/arm64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6 ... @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
  • 29. Enter Bake group “default” { targets = [“db”, “webapp-dev”] } target “webapp-dev” { dockerfile = "Dockerfile.webapp" tags = ["docker.io/username/webapp"] } target “webapp-release” { inherits = [“webapp-dev”] platforms = [“linux/amd64”, “linux/arm64”] } @adrianmouat
  • 30. Bake ■ docker buildx bake ■ docker buildx bake release ■ docker buildx bake test validate lint ■ docker buildx bake binaries-cross ■ docker buildx bake help @adrianmouat
  • 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