Kubectl:在Windows下为正在运行的容器获取一个shell

Kubectl:在Windows下为正在运行的容器获取一个shell,windows,shell,kubectl,Windows,Shell,Kubectl,根据中的说明,我正在尝试使用Kubectl登录运行容器,但我失败得很惨: kubectl exec -it mycontainer -- /bin/bash 无法使用TTY-输入不是终端或正确的类型 文件rpc错误:code=2 desc=oci运行时错误:exec失败: container_linux.go:247:启动容器进程导致“exec: \“D:/Applications/Git/usr/bin/bash\”:stat D:/Applications/Git/usr/bin/bash

根据中的说明,我正在尝试使用Kubectl登录运行容器,但我失败得很惨:

kubectl exec -it mycontainer -- /bin/bash
无法使用TTY-输入不是终端或正确的类型 文件rpc错误:code=2 desc=oci运行时错误:exec失败: container_linux.go:247:启动容器进程导致“exec: \“D:/Applications/Git/usr/bin/bash\”:stat 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控制台中一样。

似乎它可能与这个github有关

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


您也可以尝试使用
/bin/sh
而不是
/bin/bash
它对我很有效,但我没有Windows机器在与您相同的环境中检查它

注意,
/bin/sh
并不是更好的选择,无论是使用bash for windows还是使用windows的
cmd