英文:
Powershell not starting inside Windows Servercore Docker image
问题
在启动一个基于 mcr.microsoft.com/windows/servercore:ltsc2019 的 Windows Docker 容器后,我无法在其中启动 PowerShell。
如果我从以下的 Dockerfile 创建一个镜像:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
WORKDIR /
WORKDIR /config
ADD /config/run.ps1 /config/run.ps1
CMD ["powershell", "./run.ps1"]
然后尝试使用 docker run -d -it my-image-name
运行,我可以在事件日志中看到错误代码 3221225781
。
如果我运行 docker run -it my-image-name powershell
,我会收到错误消息 failed to resize tty, using default size
,然后什么都不会发生。
如果我运行 docker run -it my-image-name cmd.exe
,我可以进入容器,但在其中运行 powershell
没有任何响应(没有错误消息或任何输出)。
我尝试禁用防病毒软件并在主机上安装 VC++ redistributables,但没有改变。
对于其他在 Windows Server 2019 主机上(非数据中心版)的客户,相同的镜像可以正常工作。
是否有任何解决方案或其他方法可以尝试调试此问题?数据中心版是否可能是问题的原因?
英文:
After starting a Windows docker container (base image mcr.microsoft.com/windows/servercore:ltsc2019) on a Windows Server 2019 Datacenter host i cannot start a powershell inside it.
If i create an image from a Dockerfile like this:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
WORKDIR /
WORKDIR /config
ADD /config/run.ps1 /config/run.ps1
CMD ["powershell", "./run.ps1"]
And try to run with docker run -d -it my-image-name
i can see the error code 3221225781
in event log.
If i run docker run -it my-image-name powershell
i get the error failed to resize tty, using default size
and then nothing happens.
If i run docker run -it my-image-name cmd.exe
i can enter the container but running powershell
inside does nothing (no error message or any output).
I tried disabling antivirus and installing VC++ redistributables on the host but no change.
The same image is working fine for other customers on Windows Server 2019 hosts (not datacenter).
Is there any solution or any additional way for me to try and debug the problem? Could the datacenter edition be a problem?
答案1
得分: 0
FROM mcr.microsoft.com/windows/servercore:ltsc2019
#WORKDIR /
#WORKDIR /config
WORKDIR c:\config
ADD run.ps1 c:\config\run.ps1
ENTRYPOINT ["powershell", "-ExecutionPolicy", "Bypass", "-NoProfile", "-File", "run.ps1"]
If I understood docker correctly on windows, the paths should also be windows
英文:
FROM mcr.microsoft.com/windows/servercore:ltsc2019
#WORKDIR /
#WORKDIR /config
WORKDIR c:\config
ADD run.ps1 c:\config\run.ps1
ENTRYPOINT ["powershell", "-ExecutionPolicy", "Bypass", "-NoProfile", "-File", "run.ps1"]
If I understood docker correctly on windows, the paths should also be windows
答案2
得分: 0
I'm assuming that run.ps1 is in your /config folder in your build context? If so, you're defining /config as your working directory. If you want to copy the script into there just use the current directory. <dest> is relative to your working directory if you use a relative path. All subsequent commands will use the working directory as your base path.
FROM mcr.microsoft.com/windows/servercore:ltsc2019
WORKDIR /config
COPY /config/run.ps1 .
ENTRYPOINT ["powershell", "-File","run.ps1"]
CMD ["powershell"]
英文:
I'm assuming that run.ps1 is in your /config folder in your build context? If so, you're defining /config as your working directory. If you want to copy the script into there just use the current directory. <dest> is relative to your working directory if you use a relative path. All subsequent commands will use the working directory as your base path.
FROM mcr.microsoft.com/windows/servercore:ltsc2019
WORKDIR /config
COPY /config/run.ps1 .
ENTRYPOINT ["powershell", "-File","run.ps1"]
CMD ["powershell"]
答案3
得分: 0
终于找到了问题:Kaspersky。
如问题中所述,我尝试停用它,但没有任何改变。有效的方法是彻底卸载Kaspersky。
英文:
Finally figured out the problem: Kaspersky.
As stated in the question i tried deactivating it but that didn't make a difference. What worked was completely uninstalling Kaspersky..
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论