Chris G.
Chris G.

Reputation: 25974

docker build keep building wrong architecture

The following Dockerfile keeps building for wrong architecture:

Note I can not use buildx as I need to install specific tools for different architectures

arm64/Dockerfile

# syntax=docker/dockerfile:1

# Download arm64 specifict tools

FROM golang:1.17.2 as build

WORKDIR /source

COPY src/go.mod ./
COPY src/go.sum ./
RUN go mod download

COPY src/ ./
RUN env GOOS=linux GOARCH=arm64 go build -o /app

docker build:

docker build \
--target build -t $CURRENT_REGISTRY/mycontainer:arm64 \
-f ./docker/$ARCH/Dockerfile .

docker inspect:

docker inspect manifest $CURRENT_REGISTRY/mycontainer:arm64

Output:(should be arm64 and not amd64)?

 ...
 "Architecture": "amd64",
        "Os": "linux",
        "Size": 323727784,
        "VirtualSize": 323727784,
 ...

Upvotes: 0

Views: 771

Answers (1)

Chris G.
Chris G.

Reputation: 25974

Just use docker buildx build and not just build on each platform. Then use docker docker manifest create.

Upvotes: 1

Related Questions