Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I configure docker buildx build to use the --load option by default?

I have a bunch of shell scripts that run docker build to build Docker images, something like

#!/bin/bash

docker build -t my.registry/image1:latest dir1
docker build -t my.registry/image2:latest dir2
...

These images need to run on a linux/amd64 machine. Previously the Docker images were built on linux/amd64 machines, but now I need to additionally be able to build these images on an M1 MacBook (ARM64) as well. Is there a way to configure and use a Buildx builder on my MacBook so that these scripts can be run there without change? I found that I can configure a Buildx builder to only compile for linux/amd64 and can alias docker build to docker buildx build:

docker buildx create --platform linux/amd64 --name mybuilder
docker buildx use mybuilder
docker buildx install

but I still need to specify the --load option. Is there a way to configure that as a default as well or do I just have to update the scripts (and require Linux users to install Buildx)?

I've looked through various documentation pages with no luck, so it may not be possible but I just want to make sure I'm not missing something.

like image 544
Paul Li Avatar asked Dec 18 '25 03:12

Paul Li


1 Answers

You can by setting --driver-opt=default-load=true when creating the buildx builder.

docker buildx create --name multi-arch --platform=linux/amd64,linux/arm64 --driver-opt=default-load=true --driver=docker-container
like image 129
Jason Greathouse Avatar answered Dec 20 '25 01:12

Jason Greathouse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!