带有 dotnet 的 alpine docker 图像看不到我的应用程序

Fox*_*Net 3 .net asp.net docker .net-core alpine-linux

我正在尝试使用 Alpine Linux docker 映像运行我的 dotnet 5 单文件应用程序。这是我的 Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine    
WORKDIR /app
COPY ["Service.Translations", "/app/Service.Translations"]

CMD ["./Service.Translations", "--urls", "http://0.0.0.0:5000"]
Run Code Online (Sandbox Code Playgroud)

这是依赖于框架的应用程序。也尝试使用独立的,结果是相同的:未找到。Dotnet 看不到我的文件,sh 也看不到。

这是因为我在 Windows 上构建应用程序而导致的问题吗?所有教程均在图像内包含 alpine 编译应用程序。如果我将 Alpine 更改为 Ubuntu 或其他 - 一切都可以。

更新:好的,问题出在发布上。我必须将 --runtime 更改为 linux-musl-x64 而不是 linux-x64

Fox*_*Net 8

我发现了问题。Alpine Linux 使用 musl c 库,这使得标准 dotnet 构建与该 Linux 发行版不兼容。Visual Studio 不具备所有发布运行时选项。在这里https://learn.microsoft.com/en-us/dotnet/core/rid-catalog您可以找到所有这些。因此对于 alpine linux 我们必须使用 linux-musl-x64 运行时而不是 linux-x64