From 2a249a891a1a59733d22f63645430a552c2bd8a9 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Tue, 5 Apr 2022 21:18:57 -0700 Subject: [PATCH] docs: add cross-compile notes to multi-platform docs Signed-off-by: Tonis Tiigi --- docs/multi-platform.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/multi-platform.md b/docs/multi-platform.md index 8506e885b3ac..73331bfa6846 100644 --- a/docs/multi-platform.md +++ b/docs/multi-platform.md @@ -41,3 +41,9 @@ docker run --privileged --rm tonistiigi/binfmt --install all ``` See also [`tonistiigi/binfmt` documentation](https://github.com/tonistiigi/binfmt/). + +### Builds are very slow through emulation + +Running binaries made for a different architecture through a software emulation layer is much slower than running binaries natively. Therefore this approach is not recommended for CPU intensive tasks like compiling binaries. It is provided as a simple solution to build existing Dockerfiles and usually works well for common tasks like installing packages and running scripts. To get native performance for compilation steps you should modify your Dockerfile to perform cross-compilation using [predefined platform ARGs](https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope). Learn more from https://medium.com/@tonistiigi/faster-multi-platform-builds-dockerfile-cross-compilation-guide-part-1-ec087c719eaf . You can also use [xx](https://github.com/tonistiigi/xx) project to add cross-compilation toolchains into Dockerfiles with minimal changes. + +[Docker Buildx](https://github.com/docker/buildx) also supports multi-node builders where single image can be built with multiple machines that each build components for their native architectures.