'Docker errors when trying to build in ARM64 Apple M1: "Failed to resolve full path of the current executable [/proc/self/exe]"
I'm having trouble building docker containers on an Apple M1 The project uses sdk 2.2 which is incompatible with arm64 architecture. So I changed the sdk and aspnet cores to 2.2-alpine3.8 and they seem to build ok but the process fails when it needs to publish
The docker file:
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine3.8 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY . .
RUN dotnet publish src/admin/MyContainer.Admin.csproj -c Release -o ./publish
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine3.8
WORKDIR /app
COPY --from=build-env /app/src/admin/publish .
# Copy script that allows waiting for the database on docker-compose
# As referenced here https://docs.docker.com/compose/startup-order/
# This was done because admin starts up very quickly on e2e env
# and the sqlserver container wasn't getting ready fast enough
COPY --from=build-env /app/docker-wait-for-it.sh .
EXPOSE 80
CMD ["dotnet", "MyContainer.Admin.dll"]
the build command I'm using is:
docker buildx build --platform linux/arm64/v8 -t MyContainer.azurecr.io/admin-api-web:development ./backend -f ./backend/Admin.Api.Web.Dockerfile
and the log output is:
[+] Building 0.5s (11/13)
=> [internal] load build definition from Admin.Api.Web.Dockerfile 0.0s
=> => transferring dockerfile: 46B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine3.8 0.1s
=> [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:2.2-alpine3.8 0.1s
=> [build-env 1/4] FROM mcr.microsoft.com/dotnet/core/sdk:2.2-alpine3.8@sha256:1299ac0379146c1de7b588196727dbd56eace3abfbdd4321c547c9ff4a18a2f7 0.0s
=> => resolve mcr.microsoft.com/dotnet/core/sdk:2.2-alpine3.8@sha256:1299ac0379146c1de7b588196727dbd56eace3abfbdd4321c547c9ff4a18a2f7 0.0s
=> [stage-1 1/4] FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine3.8@sha256:4d6e528f4c09c55804b6032ecc5d60565a3ee16f68bb08d2cf337dff99cdb8c3 0.0s
=> => resolve mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine3.8@sha256:4d6e528f4c09c55804b6032ecc5d60565a3ee16f68bb08d2cf337dff99cdb8c3 0.0s
=> [internal] load build context 0.2s
=> => transferring context: 473.91kB 0.1s
=> CACHED [stage-1 2/4] WORKDIR /app 0.0s
=> CACHED [build-env 2/4] WORKDIR /app 0.0s
=> CACHED [build-env 3/4] COPY . . 0.0s
=> ERROR [build-env 4/4] RUN dotnet publish src/admin/MyContainer.Admin.csproj -c Release -o ./publish 0.1s
------
> [build-env 4/4] RUN dotnet publish src/admin/MyContainer.Admin.csproj -c Release -o ./publish:
#11 0.127 Failed to resolve full path of the current executable [/proc/self/exe]
I've tried with different platforms on the --platform flag and without any specified as well... If I try to build with core 2.2 I get this output:
[+] Building 0.5s (4/4) FINISHED
=> [internal] load build definition from Admin.Api.Web.Dockerfile 0.0s
=> => transferring dockerfile: 745B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> ERROR [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:2.2 0.4s
=> CANCELED [internal] load metadata for mcr.microsoft.com/dotnet/core/sdk:2.2 0.4s
------
> [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:2.2:
------
error: failed to solve: failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest sha256:08xxx: not found
Which I've found out to be because core 2.2 has no support form arm64. But this file builds without any errors on an Intel MacBook but with M1 I can't get past the build error. Any ideas?
Solution 1:[1]
This is not an answer but a followup to the problem, which might shed some more light on the issue.
I'm using aspnet:6 and it passes the build.
The problem later on is that the runnable .dll throws
cannot execute binary file: Exec format error
which seems to be a platform issue, using Mac with an M1 Silicon chipset.
I have no issue with other docker images that are made for linux/amd64
The Docker daemon seems to deal with this fine (having installed Rosetta2 and the Latest Docker Desktop for M1) https://docs.docker.com/desktop/mac/apple-silicon/
Have you managed to resolve the issue and execute the dll?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | syberkitten |