From 9262eabd34acb3f0c0734ee7322634a2bc8169f9 Mon Sep 17 00:00:00 2001 From: Tomas Baca Date: Mon, 2 Dec 2024 14:21:54 +0100 Subject: [PATCH] docker --- .../30-docker/20-crossplatform-build.md | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/docs/10-prerequisities/30-docker/20-crossplatform-build.md b/docs/10-prerequisities/30-docker/20-crossplatform-build.md index a670fb05..7ec64962 100644 --- a/docs/10-prerequisities/30-docker/20-crossplatform-build.md +++ b/docs/10-prerequisities/30-docker/20-crossplatform-build.md @@ -5,3 +5,46 @@ description: How to build crossplatform Docker images --- # Crossplatform docker build + +A docker image can be build for a desired platform by adding the `--platform` parameter: + +```bash +docker build . --file Dockerfile --tag --platform=arm64 +``` + +The crossplatform build is facilitated by QEMU. +Expect a run-time approx. 10x slower than for the native platform. + +## Multi-platform docker build + +Multi-platform images can be built using the `dockerx` multiplatform builder. +First, instantiate a multiplatform builder and set it to be the default: + +```bash +docker buildx create --name container-builder --driver docker-container --bootstrap --use +``` + +Then, build an image using the `buildx` command (which uses the selected builder) and supply the `--platform` parameter with the list of the desired platforms: + +```bash +docker buildx build . --file Dockerfile --tag $REGISTRY/$LOCAL_TAG --platform=linux/arm64,linux/amd64 --push +``` + +### Listing the available docker builders + +```bash +docker buildx list +``` + +``` +NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS +container-builder docker-container + \_ container-builder0 \_ unix:///var/run/docker.sock running v0.16.0 linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/arm64, linux/riscv64, linux/ppc64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6 + default* docker + \_ default \_ default running v0.16.0 linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/arm64, linux/riscv64, linux/ppc64, linux/ppc64le, linux/s390x, linux/386, linux/mips64le, linux/mips64, linux/arm/v7, linux/arm/v6 +```` + +If you want to switch back to the default docker builder, select it then by issuing +```bash +docker buildx use default +```