This repository uses buildx
to build and publish the docker image.
At time of writing, multi-architectural builds with buildx
is an experimental feature. You'd need to enable the experimental features for docker.
To enable experimental features on Windows Docker Desktop
:
- Right click on the docker icon on the bottom right tray.
- Click on
Settings
. - Click on the
Enable Experimental Features
switch under theCommand Line
tab. - Click
Apply and Restart
.
Now to build a docker image, we'll use the new docker command line tool called buildx
.
- Navigate to where you
Dockerfile
resides.cd <PathToDockerFileDirectory>
- You need to create your custom builder, and use it. You can't use the default docker builder as it doesn't support multi-architectural builds.
docker buildx create --name <YourBuilderName> docker buildx use <YourBuilderName>
- Login to your docker image repository. This will prompt you for your username and password if you haven't logged in before.
docker login
- Now to do the actual build using
buildx
. For the most part,buildx
is just an extension to thebuild
command, meaning it has the same syntax, just a few extended flags and features, such as--platform
which we can use for multi-architectural builds.docker buildx build --platform <SupportedCpuArchitectures> -t "<YourDockerUserName>/<YourImageName>:<tag>" --push .
The
<SupportedCpuArchitectures>
is a string of CPU architectures to support, delimited by comma (e.g.linux/amd64,linux/arm/v6,linux/arm64/v8
). The CPU architectures that can be supported depends on:- The base image you're using in the
Dockerfile
. It must support the architecture you've provided. You can check what CPU architecture your base image supports through finding the image in DockerHub, click on the image, and then click on theTags
tab. There, you'd be able to see a list ofOS/Arch
it supports. Your list of supported CPU architectures must be a subset of that list. - The architecture that's supported by your installed software & architecture. You can find what is supported through running the below command:
docker buildx inspect --bootstrap
- The base image you're using in the
Here's an example with putting everything together:
cd shinobi
docker buildx create --name shinobibuilder
docker buildx use shinobibuilder
docker login
docker buildx build --platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8 -t mtran0011/shinobi --push .
If you'd like to remove your custom builder, you can use:
docker buildx use default
docker buildx rm shinobibuilder
For more information, see: