Failed to start container with specified command in json

12/25/2017

I tried multiple ways to specify docker run command but ends up with errors.

When I run kubectl get pods which returns below error in status.

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

The Json file I use for kubectl apply command to create pod is:

{
 "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"
    }
  }
}

What should I set in command?

-- raychen3
azure-container-service
kubernetes

2 Answers

12/25/2017

Docker can't find powershell.exe in you system PATH. Maybe you should use full path of powershell.exe in "command"

-- Eiven
Source: StackOverflow

12/25/2017

You are trying to launch an executable named powershell.exe -command which obviously does not exist. What you should try to launch is more like :

command: "powershell.exe"
args:
- "-command"
- "docker run..."
-- Radek 'Goblin' Pieczonka
Source: StackOverflow