是否有可能以某种方式将 Powershell Core 添加到 AspNet Nano Server 基础映像中?
我们使用多级 dockerfile 来生成包含 .net core Web 应用程序的映像。最终映像基于 mcr.microsoft.com/dotnet/core/aspnet:3.1-nanoserver-1809,添加了我们的 .net core 二进制文件(为了将映像大小保持在最小)。
我们希望将 Powershell Core 包含在最终映像中,以用于初始化和调试目的,但到目前为止尚未找到方法。我们考虑了各种命令行安装选项(msiexec、choco 和谷歌搜索了很多),但没有找到解决方案。
很感谢任何形式的帮助!
所以我正在玩这个容器概念和特定的窗口容器.
我设法使用windows nanoserver图像运行容器,但是这个图像意味着服务并且不支持gui应用程序(或32位应用程序).
找不到任何提到运行gui应用程序(并看到gui)使用Windows容器(只找到linux容器gui).
有没有办法在容器中运行GUI应用程序?那么如何创建包含此支持的自己的图像?
我创建了一个运行docker的W10 VM(guest),拉出了microsoft/nanoserver图像并托管了一个容器的图像.
(这里的教程:https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start_windows_10)
一切都运行良好,甚至主机可以ping客户W10下运行的容器.但我不能做的是将远程PowerShell连接到容器.
Enter-PSSession -ComputerName "<container ip>" -Credential ~\Administrator
Run Code Online (Sandbox Code Playgroud)
这会弹出一个询问用户和密码的对话框.我不能把它留空或等 - 结果是访问被拒绝.有关如何连接或设置nanoserver容器密码的任何想法?
我最近尝试在 Windows Server 2019 实例上拉取并运行 Docker 映像(在 Windows 10 上运行),但失败并显示以下错误消息:
容器操作系统与主机操作系统不匹配。
我试过它的最新版本Windows Server Core
,并Nano Server
从正常microsoft/windowsservercore
和microsoft/nanoserver
仓库。
我不明白,因为那些是在 Windows 操作系统上运行的 Windows 内核。
构建我的 Windows dockerfile (.net core nano) 时...
docker build -f *** -t ***:*** --build-arg ARG1=foo --build-arg ARG2=bar .
我在构建过程中收到一个错误,该错误是响应我的第一个RUN
命令而发生的。该命令将失败并显示以下消息:
ERROR: failed to solve: process "cmd /S /C dotnet restore \"myproject.csproj\"" did not complete successfully: unable to find user ContainerUser: invalid argument
就我而言,这是一个dotnet restore
命令,但任何RUN
语句都会导致:
unable to find user ContainerUser: invalid argument
请注意,Windows Nanoserver 容器的默认用户是ContainerUser
。如果我指定另一个用户,例如。USER ContainerAdministrator
在该语句之前RUN
,该用户也会发生相同的故障 ( unable to find user ContainerAdministrator: invalid argument
)。
Dockerfile 片段:
FROM mcr.microsoft.com/dotnet/sdk:7.0-nanoserver-1809 AS …
Run Code Online (Sandbox Code Playgroud) docker .net-core dockerfile nano-server github-actions-self-hosted-runners
背景
\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
我有一个Windows nano服务器,并尝试设置代理设置.nano服务器仅在命令模式下没有GUI.我在PowerShell中运行
netsh winhttp set proxy proxy-server="ipadress:8080"
Run Code Online (Sandbox Code Playgroud)
然后我有
ping www.google.de
Run Code Online (Sandbox Code Playgroud)
并且显示了谷歌的IP地址,因此存在一些连接.但是当我试着奔跑的时候
wget www.google.de
Run Code Online (Sandbox Code Playgroud)
我明白了
"Unable to connect to the remote server"
Run Code Online (Sandbox Code Playgroud)
然后我在PowerShell环境中设置了代理
set http_proxy="ipadress:8080" and https_proxy...
Run Code Online (Sandbox Code Playgroud)
但同样的问题.当我使用代理设置直接调用wget时,它可以工作:
wget 'http://www.google.de' -Proxy http://ipadress:8080
Run Code Online (Sandbox Code Playgroud)
如何才能wget
使用全局代理设置?或者设置没有正确设置?或者需要我安装一些Windows功能,它是否正常工作?
我wget
用来测试连接以后任何程序的Web请求应该工作.
有一些指南展示了如何执行此操作,但它们是不久前的,我似乎找不到它们所指的实用程序 certoc.exe。这是否已从 Nanoserver 的更高版本中删除?
https://joshuachini.com/2018/02/08/how-to-import-an-enterprise-certificate-into-a-windows-container/
https://www.ntweekly.com/2017/01/30/install-self-signed-certificate-on-windows-nano-server-2016/
有人知道我应该在哪里获得这个实用程序吗?
我在这里发现了另一个小线索 https://github.com/PowerShell/CertificateDsc/issues/45
这种情况回避了 Nano 服务器中可用的 Import-Certificate 命令。虽然我也没有找到。
任何帮助都会得到应用,干杯。
PS C:\> docker run microsoft/nanoserver:1803_KB4338819 certoc.exe
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container 3f732602c6d8fbbf9370613971a7f40993a54bc33870d3040bf5e9c2fec8969c encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLine":"certoc.exe","User":"ContainerUser","WorkingDirectory":"C:\\","CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}.
PS C:\> docker run -it microsoft/powershell:6.0.4-nanoserver-1803_kb4338819 certoc.exe
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container 285d821dccac930df5681e73842f8ce2bac812f361a6b9d14b00dcb4901a9141 encountered an error during CreateProcess: failure in a Windows system call: The system …
Run Code Online (Sandbox Code Playgroud) 我有一个使用 Windows Nano Server 基础映像并使用 Powershell 作为 shell 的 Dockerfile:
FROM microsoft/nanoserver
SHELL ["powershell"]
Run Code Online (Sandbox Code Playgroud)
我现在想使用命令定义一个变量(或通过 via 传递它--build-arg
)ARG
,然后在RUN
命令中使用它,但我似乎无法让它工作。我试过了:
ARG mydir=tmp
RUN mkdir %mydir%
RUN mkdir $mydir
Run Code Online (Sandbox Code Playgroud)
但这些都不起作用。
如何告诉 docker / powershell 正确扩展我的变量?
我需要在 Windows Server 2016 中运行 Nano 服务器 docker 映像,但每当我尝试拉取映像时都会重试..模式,我需要一些建议来解决它。命令是: docker pull mcr.microsoft.com/windows/nanoserver:10.0.14393.953
我想拉纳米服务器:1903
docker pull mcr.microsoft.com/windows/nanoserver:1903
Run Code Online (Sandbox Code Playgroud)
此命令行是从Docker Hub复制的,该页面还说,该映像是在 2 周前创建的:05/22/2019
当我执行 pull 命令时,我收到错误消息。
1903:从 windows/nanoserver 中提取
清单列表条目中没有未知的匹配清单
我缺少什么?
我使用的是 Windows 10,一些额外的诊断信息:
Swarm:非
活动 默认隔离:hyperv
内核版本:10.0 17763 (17763.1.amd64fre.rs5_release.180914-1434)
操作系统:Windows 10 Pro Version 1809(操作系统内部版本 17763.404)
OSType:windows
架构:x86_64
CPU:28
总内存:63.69GiB
调试模式(客户端): false
调试模式(服务器): true
注册表: https: //index.docker.io/v1/
实验:true
nano-server ×11
docker ×10
powershell ×6
dockerfile ×3
windows ×3
.net-core ×1
asp.net-core ×1
containers ×1
docker-image ×1
github-actions-self-hosted-runners ×1
proxy ×1
server-core ×1
wget ×1