Buildx failing to build arm64 containers

Before the default docker remote version was updated to 20.x, specifying a docker remote platform version of 20.10.14 worked for building arm64 containers. However, now removing the setting to use the default of 20.10.21 and also specifying any other 20.x version fails to build an arm64 container. What has changed that caused this?

I’m using the circleci/aws-ecr orb to build images for specific platforms when PRs/feature branches are created on my repositories. For example:

orbs:
  aws-cli: circleci/aws-cli@3
  aws-ecr: circleci/aws-ecr@8

jobs:
  build-container:
    parameters:
      platform:
        description: amd64 or arm64
        type: enum
        default: amd64
        enum: [ "amd64", "arm64" ]
    executor: python3
    steps:
      - checkout
      - setup_remote_docker:
          docker_layer_caching: true
      - aws-ecr/build-image:
          platform: linux/<< parameters.platform >>
          repo: ${CIRCLE_PROJECT_REPONAME}
          push-image: false
          tag: << parameters.platform >>-${CIRCLE_SHA1}

this produces a command like:

docker buildx build -f ./Dockerfile -t my-nginx:arm64-781102287233d907e225a876dad8c5d3c6629134 --platform linux/arm64 --progress plain --load .

and an error like:

#6 [2/7] RUN apk --update --no-cache upgrade     && apk add --no-cache bash     && mkdir -p /data/nginx/cache
#6 0.295 exec /bin/sh: exec format error
#6 ERROR: executor failed running [/bin/sh -c apk --update --no-cache upgrade     && apk add --no-cache bash     && mkdir -p /data/nginx/cache]: exit code: 1

specifying the docker version used to work, like:

- setup_remote_docker:
          version: 20.10.14
          docker_layer_caching: true

but now that is not working as well. So, why did this just stop working, and how do I fix it?

1 Like

Same issue here

Same issue. Leaving the error message I’m receiving here for others to find.

Job was rejected because this version of Docker is not supported on this resource class. Try removing the version of Docker in your .circleci/config.yml and re-running

You need to:

  1. configure docker for containerd
  2. install qemu-user-static to enable cross-arch images
    Do this on a machine executor (in my case ubuntu 22.04):
echo '{"features": {"containerd-snapshotter": true}}' | sudo tee /etc/docker/daemon.json
            sudo systemctl restart docker
            docker run --rm --privileged multiarch/qemu-user-static --reset -p yes