我有一个 Dockerfile 构建应用程序并将其发布到这样的容器
FROM mcr.microsoft.com/dotnet/sdk:5.0 as builder
COPY . ./
RUN dotnet publish Project -c Release -o ./publish
FROM mcr.microsoft.com/dotnet/runtime:5.0 as runner
COPY --from=builder /publish .
WORKDIR data
ENTRYPOINT ["dotnet", "../Project.dll"]
构建映像和运行容器在 Windows 上工作,但在 Ubuntu 服务器上不工作。
project_1 | Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly '/Project.dll'. The system cannot find the file specified.
project_1 |
project_1 | File name: '/Project.dll'
我认为问题在于为dotnet
as指定参数../Project.dll
,因为 shell 将其扩展为/Project.dll
dotnet 不理解 Linux 路径。有没有办法来解决这个问题?
我是 Docker 的初学者,也许我遗漏了一些东西(Docker 不应该在每个平台上都一样吗?)
编辑:dotnet Project.dll
在父目录内的容器中从 bash 运行会产生相同的输出