GitHub Action 的 docker 构建多架构的镜像时,报错:The job was canceled because "xxx_amd64" failed.
报错信息
Build And Push Docker Hub (ubuntu-latest, arm64)
The job was canceled because "ubuntu-latest_amd64" failed.
原因
docker/build-push-action@v4
不支持多架构构建,需要使用 buildx
# 在上一个动作 run 的最后执行
docker buildx create --use
最终代码段为:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Get Information
id: information
run: |
docker buildx create --use
- name: Build and push
id: dockerbuild
uses: docker/build-push-action@v4
with:
context: .
file: ./Containerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE }}:${{ env.BUILD_TAG }}