【发布时间】: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