Powershell 未在 Windows Servercore Docker 映像中启动

问题描述 投票:0回答:2

在 Windows Server 2019 Datacenter 主机上启动 Windows docker 容器(基础映像 mcr.microsoft.com/windows/servercore:ltsc2019)后,我无法在其中启动 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++ 可再发行组件,但没有任何变化。

对于 Windows Server 2019 主机(而非数据中心)上的其他客户,相同的图像工作正常。

是否有任何解决方案或任何其他方法可以让我尝试调试问题?数据中心版会不会有问题?

docker powershell docker-for-windows
2个回答
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"]

如果我在 windows 上正确理解 docker,路径也应该是 windows


0
投票

我假设 run.ps1 位于构建上下文中的 /config 文件夹中?如果是,则您将 /config 定义为您的工作目录。如果您想将脚本复制到那里,只需使用当前目录即可。如果您使用相对路径,则相对于您的工作目录。所有后续命令都将使用工作目录作为基本路径。

FROM mcr.microsoft.com/windows/servercore:ltsc2019
WORKDIR /config
COPY /config/run.ps1 .

ENTRYPOINT ["powershell", "-File","run.ps1"]
CMD ["powershell"]
© www.soinside.com 2019 - 2024. All rights reserved.