简体   繁体   English

尝试在 ARM64 Apple M1 中构建时出现 Docker 错误:“无法解析当前可执行文件 [/proc/self/exe] 的完整路径”

[英]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.我在 Apple M1 上构建 docker 容器时遇到问题 该项目使用与 arm64 架构不兼容的 sdk 2.2。 So I changed the sdk and as.net cores to 2.2-alpine3.8 and they seem to build ok but the process fails when it needs to publish所以我将 sdk 和 as.net 核心更改为 2.2-alpine3.8,它们似乎构建正常,但在需要发布时该过程失败

The docker file: docker 文件:

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:日志 output 是:

[+] 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:我在 --platform 标志上尝试了不同的平台,也没有任何指定...如果我尝试使用核心 2.2 构建,我得到这个 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.我发现这是因为核心 2.2 不支持 arm64。 But this file builds without any errors on an Intel MacBook but with M1 I can't get past the build error.但是这个文件在 Intel MacBook 上构建时没有任何错误,但是对于 M1,我无法克服构建错误。 Any ideas?有任何想法吗?

This is not an answer but a followup to the problem, which might shed some more light on the issue.这不是问题的答案,而是问题的后续行动,这可能会更清楚地说明问题。

I'm using as.net:6 and it passes the build.我正在使用 as.net:6 并且它通过了构建。

The problem later on is that the runnable.dll throws后来的问题是 runnable.dll 抛出

cannot execute binary file: Exec format error

which seems to be a platform issue, using Mac with an M1 Silicon chipset.这似乎是一个平台问题,使用带有 M1 Silicon 芯片组的 Mac。

I have no issue with other docker images that are made for linux/amd64我对为 linux/amd64 制作的其他 docker 图像没有问题

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/ Docker 守护程序似乎可以很好地处理这个问题(已经为 M1 安装了 Rosetta2 和最新的 Docker 桌面) https://docs.docker.com/desktop/mac/apple-silicon/

Have you managed to resolve the issue and execute the dll?您是否设法解决了问题并执行了 dll?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 arm64 架构(Apple M1)上运行 docker amd64 图像而不重建 - Running docker amd64 images on arm64 architecture (Apple M1) without rebuilding 如何在 MacOS Apple Silicon M1 arm64 主机上的 Docker 容器上运行 Puppeteer - How to run Puppeteer on a Docker container on a MacOS Apple Silicon M1 arm64 host arm64 docker 苹果硅 M1 macbook air 图像 - arm64 docker image for apple silicon M1 macbook air Apple M1 docker 映像使用什么架构:arm/v5、arm/v7、arm64/v8? - What architecture to use for Apple M1 docker image: arm/v5, arm/v7, arm64/v8? Docker(Apple Silicon/M1 预览版)sonarqube “清单列表条目中没有与 linux/arm64/v8 匹配的清单” - Docker (Apple Silicon/M1 Preview) sonarqube “no matching manifest for linux/arm64/v8 in the manifest list entries” Docker(Apple Silicon/M1 Preview)MySQL“清单条目中没有与 linux/arm64/v8 匹配的清单” - Docker (Apple Silicon/M1 Preview) MySQL "no matching manifest for linux/arm64/v8 in the manifest list entries" Docker(Apple Silicon/M1 预览版)goaws(清单列表条目中没有与 linux/arm64/v8 匹配的清单) - Docker (Apple Silicon/M1 Preview) goaws (no matching manifest for linux/arm64/v8 in the manifest list entries) 在 arm64 机器 (m1) 上构建的 arm64 docker 映像无法使用 jlink 正确创建 java 运行时 - arm64 docker image built on arm64 machine (m1) does not create java runtime correctly with jlink 尝试在 Docker Hub 上自动化 arm64 构建 - Trying to automate arm64 build on Docker Hub GitLab CI - 尝试使用 docker buildx 为 ARM64 构建 - GitLab CI - Trying to use docker buildx to build for ARM64
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM