【问题标题】:It was not possible to find any installed .NET Core SDKs on Windows Docker Desktop在 Windows Docker 桌面上找不到任何已安装的 .NET Core SDK
【发布时间】:2021-07-24 12:00:08
【问题描述】:

为什么我在 Windows Docker 桌面中运行 docker 映像时会收到此消息?

It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download

我开始构建镜像:docker build -t idp -f Dockerfile.IDP。

接下来我使用以下命令启动映像:docker run --name idp -it -dt -p 8443:443 idp

这就是我的 Dockerfile 的样子:

    FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build

    # copy this first so the restore layer gets cached when the csproj files are unchanged
    COPY ./*.sln ./
    COPY ./src/ProjectA/ProjectA.csproj ./src/ProjectA/
    WORKDIR /src
    RUN dotnet restore ./ProjectA/ProjectA.csproj
    COPY . /
    RUN dotnet build ./ProjectA/ProjectA.csproj -c release --no-restore

    FROM build AS publish
    RUN dotnet publish ./ProjectA/ProjectA.csproj -c release --no-build -o /app/publish
    COPY ./*.pfx /app/publish

    FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS runtime
    WORKDIR /app
    COPY --from=publish /app/publish ./

    RUN apk add --no-cache icu-libs
    ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
    ENV ASPNETCORE_URLS="https://+:443"
    ENV TZ=Europe/Amsterdam

    VOLUME /app

    ENTRYPOINT ["dotnet", "ProjectA.dll"]
    EXPOSE 443

我在这里错过了什么?

有时有效,有时无效。

平均想法是使用 HTTPS 在 linux 容器上运行 .NET Core 3.1 应用程序。

我已经在寻找可以帮助我的公认答案,但到目前为止我没有找到任何答案。

我让它以某种方式与以下功能一起工作:

docker pull mcr.microsoft.com/dotnet/aspnet:3.1

docker pull mcr.microsoft.com/dotnet/aspnet:latest

docker pull mcr.microsoft.com/dotnet/sdk:3.1

docker pull mcr.microsoft.com/dotnet/sdk:latest

然后使用上面给出的命令构建和运行。

它神奇地起作用了。但我并不觉得它有时有效,有时无效。启动它后,我删除了 mcr.* 拉动并再次重新启动应用程序,它仍然可以工作。 任何想法为什么以及如何将其解决为永久解决方案?

【问题讨论】:

    标签: .net docker .net-core https dockerfile


    【解决方案1】:

    根据您的情况,尝试使用sdkaspnet 图像中的new set

    • mcr.microsoft.com/dotnet/sdk:3.1-alpine

    • mcr.microsoft.com/dotnet/aspnet:3.1-alpine

    【讨论】:

    • 但是为什么我需要他们分开拉?它们已经在 Dockerfile 中定义。因为当应用程序运行时,我删除了这些拉取的图像,之后应用程序就可以工作了。我的想法是我在 dockerfile 中遗漏了一些东西。
    • 您可以尝试使用我提供的图像更改 Dockerfile 中的图像,看看这种行为是否仍然存在?
    • 您好,抱歉没有成功。我尝试在容器中运行它:dotnet dev-certs https 但它带有相同的消息。
    • dotnet dev-certs 不应该在运行时映像中工作。你可以阅读here 了解更多关于如何让他们工作的信息。
    猜你喜欢
    • 1970-01-01
    • 2021-12-10
    • 2020-05-23
    • 1970-01-01
    • 1970-01-01
    • 2020-06-18
    • 2022-11-13
    • 1970-01-01
    • 2020-06-27
    相关资源
    最近更新 更多