Reputation: 33
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.
Upvotes: 3
Views: 2428
Reputation: 179
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
Upvotes: 0