Skip to content

(1) GitHub Action and (2) commands to build Docker images in amd64 and arm64 architectures and push them to Docker Hub

Notifications You must be signed in to change notification settings

flor14/multi-arch-dockerfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Build amd64 and arm64 Docker images and push them to Docker Hub


The purpose of this repository is to share how to generate and publish Docker images to Docker Hub for various architectures.

Since Apple's New silicon chip doesn't share the default Intel chips architecture, it has an impact on how Docker is run and is used in the new Mac M1 and M2 machines.

To distribute Docker images that can generate containers on both architectures, I have compiled on this repository two methods for building either Docker images from a Dockerfile that use BuildKit (1, 2, 3).

  • Method one: GitHub Action (4)

  • Method two: Docker commands (5).


Method one: GitHub Actions

Adapted from (4)

The GitHub Action workflow build and pushes direct to DockerHub the two Docker images. There are some requirements:

  • The base image should exist in both architectures arm64 and amd64.
  • There are two SECRETS to add to the GitHub repository: DOCKER_USERNAME, DOCKER_PASSWORD.

Method two: Docker commands

Adapted from (5)

You should have Docker Desktop installed.

docker buildx create --name=mybuilder --use  
docker buildx inspect --boostrap # extra
docker ps  # extra
docker buildx build -t username/image --platform linux/amd64,linux/arm64 --push . # If you are running the command in the folder where the Dockerfile is

Note
In case of getting the following error run docker login --username=<username>

------
 > exporting to image:
------
error: failed to solve: server message: insufficient_scope: authorization failed

For more details read 6.

References

1 - Building Multi-Arch Images for Arm and x86 with Docker Desktop (2019) - Adam Parco
2 - Multi-Platform Docker Builds (2020) - Adrian Mouat
3 - How to Rapidly Build Multi-Architecture Images with Buildx (2022) - Tyler Charboneau
4 - Building multi-architecture images with GitHub Actions (2020) - Lars Kellogg-Stedman
5 - DockerCon 2021: I Have an M1 Mac, Now What? Docker in a Multi-arch World - Tonis Tiigi
6 - Multi-platform images - Docker documentation

About

(1) GitHub Action and (2) commands to build Docker images in amd64 and arm64 architectures and push them to Docker Hub

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published