无法执行Docker exec * ID * -it命令

时间:2020-01-05 04:17:12

标签: powershell docker windows-container

我正在尝试学习如何使用docker执行挂载/卷。

我尝试了以下命令
docker run -it -v C:\temp:C:\temp --name "test" mcr.microsoft.com/windows/servercore:ltsc2019

容器已构建并运行。但是,执行docker container exec 58df -it powershell

时出现以下错误
>container 58df300280ec39b4bbf1457cc9a44f60c523f91aa8d777a1ea53f8817d3c972a encountered an error during >CreateProcess: failure in a Windows system call: 
>The system cannot find the file specified. (0x2)
>[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
>[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
>[Event Detail: >onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent>.exe!00007FF60B4BB397: (caller: 00
>007FF60B46E70B) Exception(3) tid(5e4) 80070002 The system cannot find the file specified.
>    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess] 
>Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"-it >powershell","User":"ContainerUser","WorkingDirectory":"/","Environment":>>>>{"powershell":"C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,
"ConsoleSize":[0,0]}`

最糟糕的是,命令docker container exec 58df -it powershell通常可以正常工作,并且可以让我进入其他容器的交互模式,而无需使用volume and mount命令。自从我运行此mount / volume命令以来,似乎就打破了我的docker。

我尝试过:

  1. 出厂重置docker安装

  2. 使用kitematic添加环境变量,看看我是否可以链接回PowerShell命令。 add environment variable

但是它不再起作用了。如果遇到类似问题的任何人有任何意见,将不胜感激。

2 个答案:

答案 0 :(得分:0)

这真是一个愚蠢的错误。我设法找出问题所在。一直以来,我一直在Visual Studio Code中使用PowerShell执行我的docker命令,但我不知道为什么要使用PowerShell ISE执行到交互模式。 根据此链接PowerShell ISE issue 这是PowerShell ISE上的一个已知问题,我在PowerShell中进行了尝试,现在可以正常工作。

答案 1 :(得分:0)

是的。 power shell ISE 不起作用,但 windows power shell(x86) 可以