Powershell not starting inside Windows Servercore Docker image

huangapple go评论83阅读模式
英文:

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 [&quot;powershell&quot;, &quot;-File&quot;,&quot;run.ps1&quot;]
CMD [&quot;powershell&quot;]

答案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..

huangapple
  • 本文由 发表于 2023年3月9日 17:19:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75682573.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定