【问题标题】:Changing Asp.net core Docker target from Windows to Linux将 Asp.net 核心 Docker 目标从 Windows 更改为 Linux
【发布时间】:2019-09-23 15:24:20
【问题描述】:

我通过 Visual Studio 2019 创建了一个新的 ASP.net 应用程序。在创建项目时,我勾选了 Docker Support 复选框并为我的 docker 选择了 Windows。一段时间后,我决定将我的 docker 从 Windows 更改为 Linux,因为我在 Linux 容器上还有一些其他软件,并且每次我都需要切换。我做了一些研究,发现如果我更改 DockerFile 中的服务器 URL,我可以将其更改为 Linux。通过这样做,我遇到了这个错误:您的 Docker 服务器主机配置为“Linux”,但是项目的目标是“Windows”

然后我打开 Cs proj 文件并将 windows 更改为 Linux,现在我看到:无法将文件 obj\debug\netcoreapp2.1\xxxx.dll 复制到 bin\debug\netcoreapp2.1\xxxx.dll。对路径 bin\debug\netcoreapp2.1\xxxx.dll 的访问被拒绝。

我恢复了更改,但仍然看到相同的错误。

【问题讨论】:

    标签: linux docker asp.net-core


    【解决方案1】:
    • 更新你的dockerfile,用这一行替换基本指令 "来自 mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS 基础"
    • 对构建指令执行相同操作:FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
    • 更新您的 csproj 标记 DockerDefaultTargetOS 以指向 linux

    【讨论】:

      【解决方案2】:

      在 notepad++ 等文本编辑器中编辑 .csproj 文件 你应该看到 DockerDefaultTargetOS 标签,它应该是 Windows 将其更改为 Linux

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-09-20
        • 2019-01-20
        • 1970-01-01
        • 2016-10-13
        • 2021-03-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多