<p>we are in process of migrating init-container to kubernates job . so I added init-container image location in containers section of job.yaml. but shell script execution within .dockerfile of init-container is not getting invoked. Could some one help what could be wrong here?</p>
<p>job.yaml</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: &quot;{{ .Release.Name }}-init-job&quot;
  namespace: {{ .Release.Namespace }}
spec:
  template:
    metadata:
      annotations:
        linkerd.io/inject: disabled
        &quot;helm.sh/hook-delete-policy&quot;: before-hook-creation
        &quot;helm.sh/hook&quot;: pre-install,pre-upgrade,pre-delete
        &quot;helm.sh/hook-weight&quot;: &quot;-5&quot;
    spec:
      serviceAccountName: {{ .Release.Name }}-init-service-account
      containers:
        - name: app-installer
          image: artifactorylocation/test-init-container:1.0.1
          command:
            - /bin/bash
            - -c
            - echo Hello executing k8s init-container
          securityContext:
            readOnlyRootFilesystem: true
      restartPolicy: OnFailure
</code></pre>
<p>.dockerfile of test-init-container</p>
<pre><code>FROM repository/java17-ol8-x64:adddd4c

WORKDIR /

ADD target/test-init-container-ms.jar ./
ADD target/lib ./lib

ADD start.sh /
RUN chmod +x /start.sh

CMD [&quot;sh&quot;, &quot;/start.sh&quot;]
EXPOSE 8080
</code></pre>
<p>start.sh is not been executed by job.</p>

santosh jk
<p>Just replace your job.yml to avoid replacing the entrypoint(CMD):</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: &quot;{{ .Release.Name }}-init-job&quot;
  namespace: {{ .Release.Namespace }}
spec:
  template:
    metadata:
      annotations:
        linkerd.io/inject: disabled
        &quot;helm.sh/hook-delete-policy&quot;: before-hook-creation
        &quot;helm.sh/hook&quot;: pre-install,pre-upgrade,pre-delete
        &quot;helm.sh/hook-weight&quot;: &quot;-5&quot;
    spec:
      serviceAccountName: {{ .Release.Name }}-init-service-account
      containers:
        - name: app-installer
          image: artifactorylocation/test-init-container:1.0.1
          securityContext:
            readOnlyRootFilesystem: true
      restartPolicy: OnFailure
</code></pre>
