运行 具有强大功能的交互式容器 shell
Running interactive container with power shell
我正在尝试在 Windows(主机和来宾)中设置自动构建容器。现在我在容器内执行简单的 powershell 时遇到问题。我做了以下事情:
创建了这个 DockerFile:
# escape=`
FROM microsoft/windowsservercore
SHELL ["cmd", "/S", "/C"]
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
执行了这个构建命令:
docker build -t test:latest .
使用此命令启动 docker:
docker run test
PowerShell 打印此内容并且容器退出:
PS C:\>
D:\repo\docker\Teste
再次尝试使用此命令:
docker start d05ee -ai
PowerShell 打印相同的输出:
PS C:\>
D:\repo\docker\Teste
我希望在第一时间以交互方式使用容器来验证我将在其上安装的工具,但我无法做到这一点。我现在不知道是哪个错误阻止了我这样做,这是我的问题。
Obs1:具有相同参数的 windows cmd 中的 powershell 工作正常。
Obs2:我的 DockerFile 基于 this tutorial.
中的那个
Obs3:运行 这很好用:
docker run -it microsoft/windowsservercore powershell -NoLogo -ExecutionPolicy Bypass
因此我推测问题出在图像生成上。
您需要使用 -it
开关 运行 您的容器。这将使您的容器具有交互性,因此您可以四处闲逛
docker run -it test
我正在尝试在 Windows(主机和来宾)中设置自动构建容器。现在我在容器内执行简单的 powershell 时遇到问题。我做了以下事情:
创建了这个 DockerFile:
# escape=`
FROM microsoft/windowsservercore
SHELL ["cmd", "/S", "/C"]
CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]
执行了这个构建命令:
docker build -t test:latest .
使用此命令启动 docker:
docker run test
PowerShell 打印此内容并且容器退出:
PS C:\>
D:\repo\docker\Teste
再次尝试使用此命令:
docker start d05ee -ai
PowerShell 打印相同的输出:
PS C:\>
D:\repo\docker\Teste
我希望在第一时间以交互方式使用容器来验证我将在其上安装的工具,但我无法做到这一点。我现在不知道是哪个错误阻止了我这样做,这是我的问题。
Obs1:具有相同参数的 windows cmd 中的 powershell 工作正常。
Obs2:我的 DockerFile 基于 this tutorial.
中的那个Obs3:运行 这很好用:
docker run -it microsoft/windowsservercore powershell -NoLogo -ExecutionPolicy Bypass
因此我推测问题出在图像生成上。
您需要使用 -it
开关 运行 您的容器。这将使您的容器具有交互性,因此您可以四处闲逛
docker run -it test