Using Docker for building packages¶
Leverage multi-CPU architecture support¶
Docker brings multi-CPU architecture support:
Docker images can support multiple architectures, which means that a single image may contain variants for different architectures, and sometimes for different operating systems, such as Windows.
When running an image with multi-architecture support, docker will automatically select an image variant which matches your OS and architecture.
Most of the official images on Docker Hub provide a variety of architectures. For example, the busybox image supports
amd64,arm32v5,arm32v6,arm32v7,arm64v8,i386,ppc64leands390x.Docker Desktop for Mac provides
binfmt_miscmulti-architecture support, which means you can run containers for different Linux architectures such asarm,mips,ppc64leand evens390x.This does not require any special configuration in the container itself as it uses qemu-static from the Docker for Mac VM. Because of this, you can run an ARM container, like the
arm32v7orppc64levariants of the busybox image.
Hands-on¶
Emulating ARM:
docker run -it --rm arm32v7/debian:stretch-slim uname -a
docker run -it --rm balenalib/armv7hf-debian:stretch-build uname -a
Miscellaneous¶
https://ownyourbits.com/2018/06/27/running-and-building-arm-docker-containers-in-x86/
https://blog.hypriot.com/post/test-build-and-package-docker-for-arm-the-official-way/
https://blog.hypriot.com/post/setup-simple-ci-pipeline-for-arm-images/
https://www.balena.io/blog/building-arm-containers-on-any-x86-machine-even-dockerhub/
https://www.ecliptik.com/Cross-Building-and-Running-Multi-Arch-Docker-Images/
https://forums.docker.com/t/build-a-container-for-arm-architecture/34266
https://www.balena.io/docs/reference/base-images/base-images/
https://www.balena.io/docs/reference/base-images/devicetypes/
https://github.com/balena-io-library/official-images/tree/master/library
https://docs.docker.com/develop/develop-images/multistage-build/
https://medium.com/@tonistiigi/advanced-multi-stage-build-patterns-6f741b852fae