<p>As soon as I add,</p>

<pre><code>spec:
    containers:
      - args:
          - /bin/sh
          - '-c'
          - touch /tmp/healthy; touch /tmp/liveness
        env:
</code></pre>

<p>to the deployment file, the application is not coming up without any error in the description logs. The deployment succeed, but no output. Both files getting created in the container. Can I run docker build inside kubernetes deployment?</p>

<p>Below is the complete deployment yaml.</p>

<pre><code>  apiVersion: apps/v1
  kind: Deployment
  metadata:
    labels:
      app: web
    name: web
    namespace: default
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: web
        version: prod
    template:
      metadata:
        annotations:
          prometheus.io/scrape: 'true'
        labels:
          app: web
          version: prod
      spec:
        containers:
          - args:
              - /bin/sh
              - '-c'
              - &gt;-
                touch /tmp/healthy; touch /tmp/liveness; while true; do echo .;
                sleep 1; done
            env:
              - name: SUCCESS_RATE
                valueFrom:
                  configMapKeyRef:
                    key: SUCCESS_RATE
                    name: web-config-prod
            image: busybox
            livenessProbe:
              exec:
                command:
                  - cat
                  - /tmp/liveness
              initialDelaySeconds: 5
            name: web
            ports:
              - containerPort: 8080
              - containerPort: 8000
</code></pre>

Subit Das
<p>The problem was in your case is <code>container is not found</code> after finishing it's task. You told to execute a shell script to your conatainer. And after doing that the container is finished. That's why you can't see whether the files were created or not. Also it didn't put any logs. So you need to keep alive the container after creating the files. You can do that by putting a infinite while loop. Here it comes:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
name: hello
labels:
    app: hi
spec:
replicas: 1
selector:
    matchLabels:
    app: hi
template:
    metadata:
    labels:
        app: hi
    spec:
    containers:
    - name: hi
        image: busybox
        args:
        - /bin/sh
        - "-c"
        - "touch /tmp/healthy; touch /tmp/liveness; while true; do echo .; sleep 1; done"
        ports:
        - containerPort: 80
</code></pre>

<p>Save it to hello-deployment.yaml and run,</p>

<pre><code>$ kubectl create -f hello-deployment.yaml
$ pod_name=$(kubectl get pods -l app=hi -o jsonpath='{.items[0].metadata.name}')
$ kubectl logs -f $pod_name
$ kubectl exec -it -f $pod_name -- ls /tmp
</code></pre>
