Docker Community Forums

Share and learn in the Docker community.

Incorrect Architecture with Automated Builds

Hi,

I’m attempting to build images for ARM32/64 with Automated Builds. I’ve set up binfmt support in my hooks/ directory:

# ls hooks/*
hooks/post_checkout  hooks/pre_build

# cat hooks/post_checkout
#!/bin/bash

apt-get update
apt-get install -y curl binfmt-support

# cat hooks/pre_build
#!/bin/bash

docker run --rm --privileged multiarch/qemu-user-static --reset

These run fine, and my containers get built without any exec format errors. However, the architecture is incorrect when the images finish building. Instead of being flagged as ARM64v8, for instance, the architecture shows up as AMD64. The build is done as part of a multi-step build. Here is the Dockerfile contents:

FROM golang:latest as build
WORKDIR /go/src/github.com/myapp/myapp
ENV CGO_ENABLED=0
ENV GO111MODULE=on
ENV GOARCH=arm64
# cache depedency downloads
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# build
RUN make build
RUN touch /config.yaml

FROM arm64v8/alpine
WORKDIR /myapp
COPY --from=multiarch/qemu-user-static /usr/bin/qemu-aarch64-static /usr/bin/
RUN apk --no-cache add ca-certificates
COPY --from=build /go/src/github.com/myapp/myapp/bin/* /bin/
COPY --from=build /config.yaml /myapp/config.yaml

If I run docker build -f Dockerfile.arm64v8 . locally or on a Xenial VM with current docker-ce, the architecture shows up correctly. I’m only seeing this issue with Docker Hub Automated Builds.

Is there an additional step that needs to be taken to keep the image architecture intact?

1 Like