<p>I've a docker container based ReactJS based app, a shell script is defined in docker image as the ENTRYPOINT, and I'm able to use docker run image-name successfully.</p>
<p>Now the task is to use this docker image for Kubernetes deployment using standard deployment.yaml file templates, something like following</p>
<pre><code># Deployment file
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  labels:
    app: my-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      terminationGracePeriodSeconds: 120
      containers:
      - name: my-app
        imagePullPolicy: Always
        image: my-docker-image
        command: [&quot;/bin/bash&quot;]
        args: [&quot;-c&quot;,&quot;./entrypoint.sh;while true; do echo hello; sleep 10;done&quot;]
</code></pre>
<hr />
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app: my-app
  ports:
  - port: 3000
    targetPort: 3000
    protocol: TCP
    nodePort: 31110
</code></pre>
<hr />
<pre><code>spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-service
            port:
              number: 3000
</code></pre>
<p>when I do kubectl apply -f mydeployment.yaml, its creating required pod, but the entrypoint.sh script is not being executed upon creation of pod unlike direct running of docker image. Can someone please help in sharing what is wrong with above yaml file, am I missing or doing something incorrectly?</p>
<p>I also tried direclty call npm run start in command [] within yaml but no luck. I can enter in pod container using kubectl exec but I don't see react app running, I can manually execute entrypoint.sh and see the required output in browser.</p>
<p>Edit: Adding kubectl logs and describe output</p>
<p>logs: when I removed command/args from yaml and applied deploy.yaml, I get following logs as is, until starting the dev server line, there's nothing beyond that.</p>
<pre><code>&gt; myapp start /app
&gt; react-scripts start

ℹ ｢wds｣: Project is running at http://x.x.x.x/
ℹ ｢wds｣: webpack output is served from 
ℹ ｢wds｣: Content not from webpack is served from /app/public
ℹ ｢wds｣: 404s will fallback to /
Starting the development server...
</code></pre>
<p>Describe output</p>
<pre><code>Name:         my-view-85b597db55-72jr8
Namespace:    default
Priority:     0
Node:         my-node/x.x.x.x
Start Time:   Fri, 16 Apr 2021 11:13:20 +0800
Labels:       app=my-app
              pod-template-hash=85b597db55
Annotations:  cni.projectcalico.org/podIP: x.x.x.x/xx
              cni.projectcalico.org/podIPs: x.x.x.x/xx
Status:       Running
IP:           x.x.x.x
IPs:
  IP:           x.x.x.x
Controlled By:  ReplicaSet/my-view-container-85b597db55
Containers:
  my-ui-container:
    Container ID:   containerd://671a1db809b7f583b2f3702e06cee3477ab1412d1e4aa8ac93106d8583f2c5b6
    Image:          my-docker-image
    Image ID:       my-docker-image@sha256:29f5fc74aa0302039c37d14201f5c85bc8278fbeb7d70daa2d867b7faa6d6770
    Port:           &lt;none&gt;
    Host Port:      &lt;none&gt;
    State:          Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Fri, 16 Apr 2021 11:13:41 +0800
      Finished:     Fri, 16 Apr 2021 11:13:43 +0800
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Fri, 16 Apr 2021 11:13:24 +0800
      Finished:     Fri, 16 Apr 2021 11:13:26 +0800
    Ready:          False
    Restart Count:  2
    Environment:
      MY_ENVIRONMENT_NAME:                          TEST_ENV
      MY_SERVICE_NAME:                              my-view-service
      MY_SERVICE_MAIN_PORT:                         3000
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-9z8bw (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  default-token-9z8bw:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-9z8bw
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  32s                default-scheduler  Successfully assigned default/my-view-container-85b597db55-72jr8 to my-host
  Normal   Pulled     31s                kubelet            Successfully pulled image &quot;my-docker-image&quot; in 184.743641ms
  Normal   Pulled     28s                kubelet            Successfully pulled image &quot;my-docker-image&quot; in 252.382942ms
  Normal   Pulling    11s (x3 over 31s)  kubelet            Pulling image &quot;my-docker-image&quot;
  Normal   Pulled     11s                kubelet            Successfully pulled image &quot;my-docker-image&quot; in 211.2478ms
  Normal   Created    11s (x3 over 31s)  kubelet            Created container my-view-container
  Normal   Started    11s (x3 over 31s)  kubelet            Started container my-view-container
  Warning  BackOff    8s (x2 over 26s)   kubelet            Back-off restarting failed container
</code></pre>
<p>and my entrypoint.sh is</p>
<pre><code>#!/bin/bash
( export REACT_APP_ENV_VAR=env_var_value;npm run start )
exec &quot;$@&quot;
</code></pre>

<p>When you write this in a pod description:</p>
<pre><code>      containers:
      - name: my-app
        imagePullPolicy: Always
        image: my-docker-image
        command: [&quot;/bin/bash&quot;]
        args: [&quot;-c&quot;,&quot;./entrypoint.sh;while true; do echo hello; sleep 10;done&quot;]
</code></pre>
<p>The <code>command</code> argument overrides the container <code>ENTRYPOINT</code>. The above
is roughly equivalent to:</p>
<pre><code>docker run --entrypoint /bin/bash my-docker-image ...args here...
</code></pre>
<p>If you want to use the <code>ENTRYPOINT</code> from the image, then just set <code>args</code>.</p>
