<p><strong>PLEASE READ UPDATE 2</strong></p>

<p>I have a very simple EventHubClient app. It will just listen to an EventHub messages.</p>

<p>I get it running with the Docker support given in Visual Studio 2017 (Linux Container).</p>

<p>But when I try to deploy it in Kubernetes, I get "Back-off restarting failed container"</p>

<p><strong>C# Code:</strong></p>

<pre><code>public static void Main(string[] args)
{
    // Init Mapper
    AutoMapper.Mapper.Initialize(cfg =&gt;
    {
        cfg.AddProfile&lt;AiElementProfile&gt;();
    });

    Console.WriteLine("Registering EventProcessor...");

    var eventProcessorHost = new EventProcessorHost(
        EventHubPath,
        ConsumerGroupName,
        EventHubConnectionString,
        AzureStorageConnectionString,
        ContainerName
    );

    // Registers the Event Processor Host and starts receiving messages
    eventProcessorHost.RegisterEventProcessorAsync&lt;EventProcessor&gt;();

    Console.WriteLine("Receiving. Press ENTER to stop worker.");
    Console.ReadLine();
}
</code></pre>

<p><strong>Kubernetes Manifest file (.yaml):</strong></p>

<pre><code>apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: historysvc-deployment
spec:
  selector:
    matchLabels:
      app: historysvc
  replicas: 2
  template:
    metadata:
      labels:
        app: historysvc
    spec:
      containers:
      - name: historysvc
        image: vncont.azurecr.io/historysvc:v1
        ports:
        - containerPort: 80
      imagePullSecrets:
        - name: acr-auth
</code></pre>

<p><strong>kubectl get pods:</strong></p>

<pre><code>   NAME                                     READY     STATUS             RESTARTS   AGE
    historysvc-deployment-558fc5649f-bln8f   0/1       CrashLoopBackOff   17         1h
    historysvc-deployment-558fc5649f-jgjvq   0/1       CrashLoopBackOff   17         1h
</code></pre>

<p><strong>kubectl describe pod historysvc-deployment-558fc5649f-bln8f</strong></p>

<pre><code>Name:           historysvc-deployment-558fc5649f-bln8f
Namespace:      default
Node:           aks-nodepool1-81522366-0/10.240.0.4
Start Time:     Tue, 24 Jul 2018 10:15:37 +0200
Labels:         app=historysvc
                pod-template-hash=1149712059
Annotations:    &lt;none&gt;
Status:         Running
IP:             10.244.0.11
Controlled By:  ReplicaSet/historysvc-deployment-558fc5649f
Containers:
  historysvc:
    Container ID:   docker://59e66f1e6420146f6eca4f19e2801a4ee0435a34c7ac555a8d04f699a1497f35
    Image:          vncont.azurecr.io/historysvc:v1
    Image ID:       docker-pullable://vncont.azurecr.io/historysvc@sha256:636d81435bd421ec92a0b079c3841cbeb3ad410509a6e37b1ec673dc4ab8a444
    Port:           80/TCP
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Tue, 24 Jul 2018 10:17:10 +0200
      Finished:     Tue, 24 Jul 2018 10:17:10 +0200
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Tue, 24 Jul 2018 10:16:29 +0200
      Finished:     Tue, 24 Jul 2018 10:16:29 +0200
    Ready:          False
    Restart Count:  4
    Environment:    &lt;none&gt;
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-mt8mm (ro)
Conditions:
  Type           Status
  Initialized    True
  Ready          False
  PodScheduled   True
Volumes:
  default-token-mt8mm:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-mt8mm
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason                 Age              From                               Message
  ----     ------                 ----             ----                               -------
  Normal   Scheduled              1m               default-scheduler                  Successfully assigned historysvc-deployment-558fc5649f-bln8f to aks-nodepool1-81522366-0
  Normal   SuccessfulMountVolume  1m               kubelet, aks-nodepool1-81522366-0  MountVolume.SetUp succeeded for volume "default-token-mt8mm"
  Normal   Pulled                 8s (x5 over 1m)  kubelet, aks-nodepool1-81522366-0  Container image "vncont.azurecr.io/historysvc:v1" already present on machine
  Normal   Created                7s (x5 over 1m)  kubelet, aks-nodepool1-81522366-0  Created container
  Normal   Started                6s (x5 over 1m)  kubelet, aks-nodepool1-81522366-0  Started container
  Warning  BackOff                6s (x8 over 1m)  kubelet, aks-nodepool1-81522366-0  Back-off restarting failed container
</code></pre>

<p>What am I missing?</p>

<hr>

<p><strong>UPDATE 1</strong></p>

<p><strong>kubectl describe pod historysvc-deployment-558fc5649f-jgjvq</strong></p>

<pre><code>Name:           historysvc-deployment-558fc5649f-jgjvq
Namespace:      default
Node:           aks-nodepool1-81522366-0/10.240.0.4
Start Time:     Tue, 24 Jul 2018 10:15:37 +0200
Labels:         app=historysvc
                pod-template-hash=1149712059
Annotations:    &lt;none&gt;
Status:         Running
IP:             10.244.0.12
Controlled By:  ReplicaSet/historysvc-deployment-558fc5649f
Containers:
  historysvc:
    Container ID:   docker://ccf83bce216276450ed79d67fb4f8a66daa54cd424461762478ec62f7e592e30
    Image:          vncont.azurecr.io/historysvc:v1
    Image ID:       docker-pullable://vncont.azurecr.io/historysvc@sha256:636d81435bd421ec92a0b079c3841cbeb3ad410509a6e37b1ec673dc4ab8a444
    Port:           80/TCP
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Wed, 25 Jul 2018 09:32:34 +0200
      Finished:     Wed, 25 Jul 2018 09:32:35 +0200
    Ready:          False
    Restart Count:  277
    Environment:    &lt;none&gt;
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-mt8mm (ro)
Conditions:
  Type           Status
  Initialized    True
  Ready          False
  PodScheduled   True
Volumes:
  default-token-mt8mm:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-mt8mm
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason   Age                  From                               Message
  ----     ------   ----                 ----                               -------
  Warning  BackOff  2m (x6238 over 23h)  kubelet, aks-nodepool1-81522366-0  Back-off restarting failed container
</code></pre>

<p><strong>UPDATE 2</strong></p>

<p>When I run it localy with:</p>

<pre><code>docker run &lt;image&gt; 
</code></pre>

<p>it ends instantly (ignores the read line) (completes), which seems to be the problem. </p>

<p>I have to write </p>

<pre><code>docker run -it &lt;image&gt; 
</code></pre>

<p>-it at the end for it to do the read line. </p>

<p>How does kubernetes runs the docker image? Where can I set that?</p>

C3PO
<p>This can be done by attaching an argument to run with your <code>deployment</code>.</p>
<p>In your case the <strong>Kubernetes Manifest file (.yaml)</strong> should look like this:</p>
<pre><code>apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: historysvc-deployment
spec:
  selector:
matchLabels:
  app: historysvc
  replicas: 2
  template:
metadata:
  labels:
    app: historysvc
spec:
  containers:
  - name: historysvc
    image: vncont.azurecr.io/historysvc:v1
    ports:
    - containerPort: 80
    args: [&quot;-it&quot;]
  imagePullSecrets:
    - name: acr-auth
</code></pre>
<p>You can find this explained in k8s docs <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/" rel="nofollow noreferrer">inject-data-application/define-command-argument-container</a></p>
<blockquote>
<p>When you create a Pod, you can define a command and arguments for the containers that run in the Pod. To define a command, include the  <code>command</code>  field in the configuration file. To define arguments for the command, include the  <code>args</code>  field in the configuration file. The command and arguments that you define cannot be changed after the Pod is created.</p>
<p>The command and arguments that you define in the configuration file override the default command and arguments provided by the container image. If you define args, but do not define a command, the default command is used with your new arguments.</p>
</blockquote>
