Docker: Build ARM image from an AMD computer - norlab-ulaval/Norlab_wiki GitHub Wiki

Here is a small tutorial on how to build a Docker image for an ARM platform (e.g., Jetson) from a standard AMD computer

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --use --name jetsonbuilder
docker buildx inspect --bootstrap

If you get an error message from the last step related to context deadline exceeded, you can manually pull the image and redo the steps

docker pull moby/buildkit:buildx-stable-1
docker buildx rm jetsonbuilder
docker buildx create --use --name jetsonbuilder
docker buildx inspect --bootstrap

Then, go in the directory containing your docker-compose.yaml file and execeute this line to save it to your computer. You can set the image name in the docker-compose.yaml file.

docker buildx bake --set *.platform=linux/arm64 --set *.output=type=docker

To save the resulting image

docker save myuser/backend:arm64 | gzip > backend-arm64.tar.gz

On the Jetson

docker load < /tmp/all-images-arm64.tar.gz

To launch it, use devcontainer or directly docker compose with

docker compose up -d