Enable buildx for docker by adding {"experimental": "enabled"} into ~/.docker/config.json:
if [[ -a ~/.docker/config.json ]]; then echo "\n\nplease add it by hand\!"; else mkdir ~/.docker/ >& /dev/null; echo '{"experimental": "enabled"}' > ~/.docker/config.json; fi
Install "qemu-user-static"
apt install qemu-user-static
Sanitiy check on docker builder (might not be necessary anymore, or only on first ever setup)
# list all builders and delete them
docker buildx ls
docker buildx rm default
docker buildx rm somebuilder
# sometimes you have to run this several times
systemctl restart docker
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
Create a new builder and use it (might not be necessary anymore, or only on first ever setup)
docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx inspect --bootstrap
Build your images and push them online
docker buildx build --platform linux/arm64,linux/amd64,linux/armhf,linux/ppc64le,linux/s390x --push -t yourname/yourimage -f Dockerfile .
Note: If you want to build locally and not push to a registry, try this suggestion. I tried similar suggestions before and they didn't work. Another method is to set up a private dummy registry to accept the push.
This page or post was last modified on 2022-09-15 .