Kubectl:在Windows下将外壳获取到正在运行的容器

时间:2019-01-08 15:00:38

标签: windows shell kubectl

根据https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/中的说明,我正在尝试使用Kubectl登录正在运行的容器,但我失败了:

kubectl exec -it mycontainer -- /bin/bash
  

无法使用TTY-输入的不是终端或正确的类型   文件rpc错误:代码= 2 desc = oci运行时错误:exec失败:   container_linux.go:247:启动容器进程引起“执行:   \“ D:/ Applications / Git / usr / bin / bash \”:统计信息   D:/ Applications / Git / usr / bin / bash:没有这样的文件或目录“

     

命令以退出代码126终止

看起来kubectl试图在我的机器上执行bash,这完全不是我想要实现的。

我可以执行不带空格的命令:

$ kubectl exec mycontainer 'ls'
lib
start.sh

但没有:

$ kubectl exec mycontainer 'ls .'
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"ls .\": executable file not found in $PATH"

command terminated with exit code 126

我做错了什么?

我在mingw git shell中都尝试过,就像使用普通Windows控制台一样。

1 个答案:

答案 0 :(得分:1)

似乎与该github issue.

有关

解决方法之一可能是使用here指定的winpty。
winpty kubectl.exe exec -it pod-name -- sh

您也可以尝试使用/bin/sh代替/bin/bash,它对我有用,但是我没有Windows计算机可以在与您相同的环境中对其进行检查。