我尝试了多种方法来指定docker run命令但最终会出错。
当我运行kubectl get pods
时,状态会返回以下错误。
rpc error: code = 2 desc = failed to start container "3329716cb47a0f795b2372dd630ca1017b0bad8bf4ab0e05490d1ac5eb28ca1b": Error response from daemon: {"message":"container 3329716cb47a0f795b2372dd630ca1017b0bad8bf4ab0e05490d1ac5eb28ca1b encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {\"ApplicationName\":\"\",\"CommandLine\":\"\\\"powershell.exe -command\\\" \\\"docker run -e VSTS_ACCOUNT=apidrop -e VSTS_TOKEN=5zcp7yf5h2dofz642eykiwpo6lj6kniu4jkmgxljipocab4vc2wa -e VSTS_POOL=apexpool --name winvs2017_vstsagent raychen320/buildagent:1.0\\\"\",\"User\":\"\",\"WorkingDirectory\":\"C:\\\\BuildAgent\",\"Environment\":{\"DOTNET_DOWNLOAD_URL\":\"https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/1.0.4/dotnet-win-x64.1.0.4.zip\",\"DOTNET_SDK_DOWNLOAD_URL\":\"https://dotnetcli.blob.core.windows.net/dotnet/Sdk/1.0.1/dotnet-dev-win-x64.1.0.1.zip\",\"DOTNET_SDK_VERSION\":\"1.0.1\",\"DOTNET_VERSION\":\"1.0.4\",\"KUBERNETES_PORT\":\"tcp://10.0.0.1:443\",\"KUBERNETES_PORT_443_TCP\":\"tcp://10.0.0.1:443\",\"KUBERNETES_PORT_443_TCP_ADDR\":\"10.0.0.1\",\"KUBERNETES_PORT_443_TCP_PORT\":\"443\",\"KUBERNETES_PORT_443_TCP_PROTO\":\"tcp\",\"KUBERNETES_SERVICE_HOST\":\"10.0.0.1\",\"KUBERNETES_SERVICE_PORT\":\"443\",\"KUBERNETES_SERVICE_PORT_HTTPS\":\"443\",\"NUGET_XMLDOC_MODE\":\"skip\",\"chocolateyUseWindowsCompression\":\"false\"},\"EmulateConsole\":false,\"CreateStdInPipe\":true,\"CreateStdOutPipe\":true,\"CreateStdErrPipe\":true,\"ConsoleSize\":[0,0]}"} 0 26s
我用于kubectl apply命令创建pod的Json文件是:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "buildagent",
"labels": {
"name": "buildagent"
}
},
"spec": {
"containers": [
{
"name": "buildagent",
"image": "raychen320/buildagent:1.0",
"command": [
"powershell.exe -command",
"docker run -e VSTS_ACCOUNT=apitest -e VSTS_TOKEN=tgctxxx -e VSTS_POOL=testpool --name myagent raychen320/buildagent:1.0"
],
"ports": [
{
"containerPort": 80
}
]
}
],
"nodeSelector": {
"beta.kubernetes.io/os": "windows"
}
}
}
我应该在命令中设置什么?
答案 0 :(得分:1)
您正在尝试启动一个名为powershell.exe -command
的可执行文件,该文件显然不存在。你应该尝试推出的更像是:
command: "powershell.exe"
args:
- "-command"
- "docker run..."
答案 1 :(得分:0)
Docker在您的系统路径中找不到powershell.exe。 也许你应该在“命令”
中使用powershell.exe的完整路径