【问题标题】:Enable Remote Desktop on Windows 10 Container在 Windows 10 容器上启用远程桌面
【发布时间】:2021-05-15 03:24:59
【问题描述】:

我正在尝试在容器映像上启用远程桌面。

Dockerfile

FROM mcr.microsoft.com/windows:2004

EXPOSE 3389

RUN net user administrator Stack0verflow
RUN net user administrator /active:yes

# I tried disabling the firewall; but this command errors as Windows Defender Firewall service 
# is not enabled; so presumably if the firewall's not running, it's not a firewall issue.
#RUN netsh advfirewall set allprofiles state off

# switch shell to powershell (note: pwsh not available on the image)
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $ExecutionPolicy = 'Unrestricted';"]

# enable RDP (value is 1 on the base image)
RUN Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name 'fDenyTSConnections' -Type 'DWord' -Value 0
# per https://www.withinrafael.com/2018/03/09/using-remote-desktop-services-in-containers/
RUN Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name 'TemporaryALiC' -Type 'DWord' -Value 1

注意:由于它是 Windows 映像,我已将 Docker Desktop 切换到 Windows Containers(参考:Docker: "no matching manifest for windows/amd64 in the manifest list entries"

然后我通过以下方式构建此图像:docker build -t win10poc .

...并通过以下方式运行它:docker run --expose 3389 --publish 3390:3389 -it win10poc

容器运行成功;但我无法连接到它(在主机设备上使用mstsc 和计算机名称127.0.0.1:3390;甚至可以使用Test-NetConnection -ComputerName 127.0.0.1 -Port 3390)。

我也尝试过从容器的命令提示符运行powershell -command "Test-NetConnection -ComputerName 'localhost' -Port 3389";但这也会返回失败;提示该服务未在此端口上侦听。

注意:在容器上运行net start TermService会返回The requested service has already been started;所以它应该在听。

我的主机设备运行的是 Windows 10.0.19041.264。

注意:我已经看到Windows Server 的类似问题;尽管再次询问是针对服务器而不是桌面,但该问题对已尝试内容的信息较少,并且没有答案。因此,我希望这不会被视为重复。

【问题讨论】:

    标签: docker windows-10 containers remote-desktop terminal-services


    【解决方案1】:

    用于构建 Dockerfile 的 reference you used 指出,在 1709_KB4074588 之后,RDP 无法再工作。今天提取该标签也不起作用:您从服务器获得响应,但无法执行任何操作。我不知道 windows 和 servercore 映像在一般情况下和 RDP 方面有何不同,除此之外,我绝不是 windows 专家。 到目前为止我的经验(使用 xfreerdp 作为客户端):

    • windows/servercore:1607 cexecsvc 正在运行,端口 3389 未侦听
    • windows/servercore:1709 可以连接到 RDP,但执行应用程序会导致 ERRINFO_LOGOFF_BY_USER
    • windows/servercore:1709_KB4074588 的行为与 1709 相同

    研究还表明您需要禁用远程执行白名单(不知道正确的名称)。

    • reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v fAllowUnlistedRemotePrograms /t REG_DWORD /d 1
    • reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TSAppAllowList" /v fDisabledAllowList /t REG_DWORD /f /d 1

    阅读brief about sessions, desktops and stations 后,我编写了一个快速测试枚举会话(请参阅LsaEnumerateLogonSessionsLsaGetLogonSessionData),并看到虽然正常的 RDP 会话会显示同一用户和少数几个(为什么?不知道)会话其中是交互式的(在我的情况下为 10 - CachedInteractive) Docker 实例中的控制台显示类型 5 的 ContainerAdministrator 用户的单个会话(代理 - 不支持),所以据我了解,没有办法从中获取交互式桌面本次会议。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-16
      • 2022-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多