Skip to content

standard_init_linux.go:228: exec user process caused: exec format error after building docker image on MacBook M1 Max for linux/amd64 platform #5526

Answered by lbussell
skoruba asked this question in Q&A
Discussion options

You must be logged in to vote

Without seeing your updated Dockerfile, it's hard to tell what's going wrong. I think you most likely need to remove the --platform $BUILDPLATFORM from your base (runtime) layer. Then it will be implicitly set to $TARGETPLATFORM by Docker.

Then your Dockerfile would be:

# Remove --platform=$BUILDPLATFORM
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base 

WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build

# Add ARG TARGETARCH and `-a $TARGETARCH` build arguments.
ARG TARGETARCH

WORKDIR /src
COPY ["src/MyProject/MyProject.csproj", "src/MyProject/"]
RUN dotnet restore -a $TARGETARCH "src/MyProject/MyProject.csproj"
COPY . .
WORKDIR "…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@skoruba
Comment options

@lbussell
Comment options

Answer selected by lbussell
@skoruba
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5523 on June 03, 2024 20:46.