Windows HostProcess Pod: “failed to get application name from commandine: failed to find executable”

  • Post category:Kubernetes

Error: failed to start containerd task "hostprocesspod": failed to get application name from commandline "/usr/local/bin/app.exe": failed to find executable "/usr/local/bin/app.exe": unknown

Here we will find out what causes this mysterious “Failed to find application name from commandline” error when launching a Windows HostProcess Pod

Source code

Create a Windows HostProcess Kubernetes cluster

To create a Windows HostProcess capable Kubernetes cluster we will use AKS-Engine

The make-aks-engine-cluster.ps1 script along with the win-hostprocess-cluster.json file does this for you, all you need to provide is a valid subscription_id

The key thing to note in win-hostprocess-cluster.json is the --feature-gates flag set to WindowsHostProcessContainers=true which allows this cluster to host HostProcess pods

make-aks-engine-cluster.ps1
win-hostprocess-cluster.json
Creating a Windows HostProcess capable Kubernetes cluster using AKS-Engine

Containerize a simple go-lang application

Next we will “containerize” a simple go-lang application

Check out the source code for file placement but essentially, you just run this docker command with the Dockerfile one directory above app.go:

shell
Dockerfile
app.go
Containerize the simple go-lang app using Docker

Launch the HostProcess pod: “failed to get application name from command line” fixed

This error is so mysterious.

The fix is simple.

HostProcess pods are run as Windows host processes, so they inherit the same file structure as the Windows host.

That means, if in your Dockerfile you specified the entrypoint of the app as an absolute file path like I did i.e. /usr/local/bin/app.exe, then the HostProcess pod will try to find that executable on the Windows host but it can’t.

To get around this, you need to use the %CONTAINER_SANDBOX_MOUNT_POINT% environment variable in an command field in your deployment yaml like so:

hostprocesspod.yaml

Now you should be able to launch your pod seamlessly like so:

kubectl
Successfully launching the HostProcess pod, you did it!

Leave a Reply