背景
\n\n我有一个 .NET 应用程序,我想将其安装在 Nano Server Docker 容器内,特别是构建 1809。该应用程序基本上是一个 REST 服务器,它将接收 REST 请求,并根据 JSON 的内容调用特定的 PowerShell cmdlet在特定的远程系统上并以 JSON 格式返回结果。
\n\n我能够创建一个安装了 PowerShell 和 .NET Core 的 Nano Server Docker 容器。然而,我最终意识到容器上没有安装 WinRM,因此无法调用远程 PowerShell cmdlet。
\n\n我的主机系统是 Windows Server 2019 Datacenter,版本 1809(操作系统内部版本 17763.379)。我正在使用适用于 Windows 的 Docker Desktop(版本 2.0.0.3)并启用了 Windows 容器。
\n\nDockerfile
\n\n这是我正在使用的 Dockerfile。我通过结合此处和此处的部分 Dockerfile 创建了它。
\n\n# escape=`\n# Args used by from statements must be defined here:\nARG fromTag=1809\nARG InstallerVersion=nanoserver\nARG InstallerRepo=mcr.microsoft.com/powershell\nARG NanoServerRepo=mcr.microsoft.com/windows/nanoserver\n\n# Use server core as …Run Code Online (Sandbox Code Playgroud) powershell powershell-remoting docker dockerfile nano-server