在Win10机器上运行Docker。 Linux容器已启用。我的应用程序在Windows和Debian图像上运行良好,但当我切换到Alpine时出现此错误
PS C:\Code\TestApp> docker run -it testapp:latest
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/app/TestApp\": stat /app/TestApp: no such file or directory": unknown.
我尝试更改Entrypoint以匹配一些示例,但没有骰子。
FROM microsoft/dotnet:2.1-runtime-deps-alpine3.7 AS base
WORKDIR /app
FROM microsoft/dotnet:2.1-sdk-alpine3.7 AS build
WORKDIR /src
COPY TestApp/TestApp.csproj TestApp/
RUN dotnet restore TestApp/TestApp.csproj
COPY . .
WORKDIR /src/TestApp
RUN dotnet build TestApp.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish TestApp.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
# This is for Windows and Debian images
# ENTRYPOINT ["dotnet", "TestApp.dll"]
ENTRYPOINT ["/app/TestApp"]
答案 0 :(得分:1)
在此多阶段构建的不同阶段添加一些调试信息:
RUN ls -alrth /app
(在每个COPY
或RUN dotnet
命令之后)
并确保使用与Windows的第一个版本不同的名称和标记构建它,以确保不在Linux环境中尝试使用Windows构建的图像。
docker build -t testApp-linux ...