All Projects → ckulka → Docker Multi Arch Example

ckulka / Docker Multi Arch Example

TL;DR reference for building multi-arch Docker images

Projects that are alternatives of or similar to Docker Multi Arch Example

Reko
Reko is a binary decompiler.
Stars: ✭ 942 (+1582.14%)
Mutual labels:  arm
Iotz
compile things easy 🚀
Stars: ✭ 39 (-30.36%)
Mutual labels:  arm
Raspberrypi tempmon
Raspberry pi CPU temperature monitor with many functions such as logging, GPIO output, graphing, email, alarm, notifications and stress testing. Python 3.
Stars: ✭ 52 (-7.14%)
Mutual labels:  arm
Python27 Arm Xcompile
Build script and patches for cross-compiling Python 2.7.3 to target ARM
Stars: ✭ 30 (-46.43%)
Mutual labels:  arm
Ws Ldn 4
Interactive DIY Synth / ARM baremetal workshop (London, 23-24 January 2016)
Stars: ✭ 36 (-35.71%)
Mutual labels:  arm
Simde
Implementations of SIMD instruction sets for systems which don't natively support them.
Stars: ✭ 1,012 (+1707.14%)
Mutual labels:  arm
Cloudguardiaas
Check Point CloudGuard Network Security repository containing solution templates, Terraform templates, tools and scripts for deploying and configuring CloudGuard Network Security products.
Stars: ✭ 27 (-51.79%)
Mutual labels:  arm
Mylinux
myLinux is a small UNIX like OS for embedded systems based on Westermo NetBox
Stars: ✭ 53 (-5.36%)
Mutual labels:  arm
Desmume
DeSmuME is a Nintendo DS emulator
Stars: ✭ 989 (+1666.07%)
Mutual labels:  arm
Redasm
The OpenSource Disassembler
Stars: ✭ 1,042 (+1760.71%)
Mutual labels:  arm
Freertos Cell
FreeRTOS for Jailhouse Cells
Stars: ✭ 31 (-44.64%)
Mutual labels:  arm
Prettyos
A Preemptive Hard Real Time kernel for embedded devices.
Stars: ✭ 36 (-35.71%)
Mutual labels:  arm
Tinygo
Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
Stars: ✭ 9,068 (+16092.86%)
Mutual labels:  arm
Reverse Engineering
This repository contains some of the executables that I've cracked.
Stars: ✭ 29 (-48.21%)
Mutual labels:  arm
Dockerpi
A Virtualised Raspberry Pi inside a Docker image
Stars: ✭ 1,064 (+1800%)
Mutual labels:  arm
Ferret
Ferret is a free software lisp implementation for real time embedded control systems.
Stars: ✭ 878 (+1467.86%)
Mutual labels:  arm
Rt0s
Minimal Realtime OS for Cortex-M0
Stars: ✭ 41 (-26.79%)
Mutual labels:  arm
Ncnn Android Styletransfer
The style transfer android example
Stars: ✭ 54 (-3.57%)
Mutual labels:  arm
Archiso Pbp
archiso customized for the Pinebook Pro
Stars: ✭ 52 (-7.14%)
Mutual labels:  arm
Walkgeek
ARM Cortex-M4 MP3 and Opus audio player
Stars: ✭ 45 (-19.64%)
Mutual labels:  arm

Docker multi-arch example

This repository demonstrates how to create a multi-arch Docker image supporting multiple platforms, e.g. both x86_64 and ARM, but building all images on an x86_64 platform. It is primarily for personal use for reference on how to build manifests and how they work.

This example also only relies on Docker Hub to build all images, including the ARM variants, and does not rely on separate build servers or environments to build non-amd64 images.

It's a TL;DR version of the references linked in the README.

Steps

To create a multi-arch image, follow the next 4 steps

  1. Build and push the image for the amd64 platform
  2. Build and push the image for the arm* platforms
  3. Create the manifest for the multi-arch image
  4. Push the maniest for the multi-arch image

Automated builds via Docker Hub

The Docker Hub Custom build phase hooks allow in combination with QEMU an entirely automated build of the Docker images via Docker Hub for all major platforms - as it is used in this repository.

To see how it's done in this repository, see

Push multi-arch manifest automatically (Docker Hub)

Once Docker Hub has published the amd64 and arm* images, Docker Hub executes the hooks/post_push script.

The script downloads the manifest-tool and pushes the multi-arch manifest multi-arch-manifest.yaml, which - simply put - makes ckulka/multi-arch-example:latest a list containing references to the various platform variants.

To see how it's done in this repository, see

Push the multi-arch manifest manually (manifest-tool)

If you want to push the multi-arch manifest yourself using the manifest-tool, here are the steps:

  1. Create the mulit-arch manifest file, e.g. multi-arch-manifest.yaml
  2. Download the manifest-tool
  3. Push the manifest using manifest-tool
# Download the manifest-tool
curl -Lo manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-amd64
chmod +x manifest-tool

# Push the multi-arch manifest
./manifest-tool push from-spec multi-arch-manifest.yaml

# On Docker for Mac, see https://github.com/estesp/manifest-tool#sample-usage
./manifest-tool --username ada --password lovelace push from-spec multi-arch-manifest.yaml

For more details, see manifest-tool: Create/Push.

Push the multi-arch manifest manually (Docker CLI)

If you want to push the multi-arch manifest yourself using the Docker CLI, here's how.

As long as the docker manifest commands are experimental, enable the experimental mode for the Docker CLI in ~/.docker/config.json first:

{
    "experimental": "enabled"
}

Next up, create and publish multi-arch the manifest.

# Create and push the manifest
docker manifest create ckulka/multi-arch-example:latest ckulka/multi-arch-example:amd64 ckulka/multi-arch-example:arm32v7
docker manifest push --purge ckulka/multi-arch-example:latest

The created manifest acts as a reference for the linked images. The Docker client, when pulling ckulka/multi-arch-example:latest, looks up a "fitting" image and then uses that one.

The --amend parameters allows adding additional platforms:

docker manifest create --amend ckulka/multi-arch-example:latest ckulka/multi-arch-example:arm64v7

The --purge parameter deletes the local manifest, which allows recreating and subsequently replacing the list:

# Release version 1.0 as latest image variant
docker manifest create ckulka/multi-arch-example:latest ckulka/multi-arch-example:1.0-amd64 ckulka/multi-arch-example:1.0-arm32v7
docker manifest push --purge ckulka/multi-arch-example:latest

# Release version 2.0 as latest image variant
docker manifest create ckulka/multi-arch-example:latest ckulka/multi-arch-example:2.0-amd64 ckulka/multi-arch-example:2.0-arm32v7
docker manifest push --purge ckulka/multi-arch-example:latest

Inspecting the result

The docker manifest inspect command shows the image manifest details - for the multi-arch image, it's the list of images it references and their respective platforms:

docker manifest inspect ckulka/multi-arch-example:latest
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1728,
         "digest": "sha256:3a859e0c2bdfb60f52b2c805e2cb55260998b3c343d9e2ea04a742d946be1b1e",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 1728,
         "digest": "sha256:3ef9264d6e5ad96ad7bac675d40edf265ae838ae6ca60865abed159c8c5124c8",
         "platform": {
            "architecture": "arm",
            "os": "linux"
         }
      }
   ]
}

Known limitations

Building non-x86_64 images on Docker Hub results in images with incorrectly labelled architectures.

For example, the arm32v7 image runs on arm32v7, but will labelled as amd64, because Docker Hub builds the images on x86_64. There is a workaround for it, but I've not added it here to keep things simple.

This issue is currently tracked in moby/moby#36552.

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].