<p>I wrote a job and I always get init error. I have noticed that if I remove the related <code>command</code> all goes fine and I do not get any init error.
My question is: how can I debug commands that need to run in the job? I use pod describe but all I can see is an exit status code 2.</p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: database-import
spec:
  template:
    spec:
      initContainers:
        - name: download-dump
          image: google/cloud-sdk:alpine
           command: #####            ERROR HERE!!!
             - bash
             - -c
             - "gsutil cp gs://webshop-254812-sbg-data-input/pg/spryker-stg.gz /data/spryker-stage.gz"
      volumeMounts:
        - name: application-default-credentials
          mountPath: "/secrets/"
          readOnly: true
        - name: data
          mountPath: "/data/"
      env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /secrets/application_default_credentials.json
  containers:
    - name: database-import
      image: postgres:9.6-alpine
      command:
        - bash
        - -c
        - "gunzip -c /data/spryker-stage.gz |  psql -h postgres -Uusername -W spy_ch "
      env:
        - name: PGPASSWORD
          value: password
      volumeMounts:
        - name: data
          mountPath: "/data/"
  volumes:
    - name: application-default-credentials
      secret:
        secretName: application-default-credentials
    - name: data
      emptyDir: {}
  restartPolicy: Never
backoffLimit: 4
</code></pre>

<p>And this is the job describe:</p>

<pre><code>Name:           database-import
Namespace:      sbg
Selector:       controller-uid=a70d74a2-f596-11e9-a7fe-025000000001
Labels:         app.kubernetes.io/managed-by=tilt
Annotations:    &lt;none&gt;
Parallelism:    1
Completions:    1
Start Time:     Wed, 23 Oct 2019 15:11:40 +0200
Pods Statuses:  1 Running / 0 Succeeded / 3 Failed
Pod Template:
Labels:  app.kubernetes.io/managed-by=tilt
       controller-uid=a70d74a2-f596-11e9-a7fe-025000000001
       job-name=database-import
Init Containers:
 download-dump:
 Image:      google/cloud-sdk:alpine
Port:       &lt;none&gt;
Host Port:  &lt;none&gt;
Command:
  /bin/bash
  -c
  gsutil cp gs://webshop-254812-sbg-data-input/pg/spryker-stg.gz /data/spryker-stage.gz
Environment:
  GOOGLE_APPLICATION_CREDENTIALS:  /secrets/application_default_credentials.json
Mounts:
  /data/ from data (rw)
  /secrets/ from application-default-credentials (ro)
Containers:
 database-import:
 Image:      postgres:9.6-alpine
 Port:       &lt;none&gt;
 Host Port:  &lt;none&gt;
 Command:
   /bin/bash
   -c
   gunzip -c /data/spryker-stage.gz |  psql -h postgres -Uusername -W 
spy_ch 
Environment:
  PGPASSWORD:  password
Mounts:
  /data/ from data (rw)
Volumes:
 application-default-credentials:
Type:        Secret (a volume populated by a Secret)
SecretName:  application-default-credentials-464thb4k85
Optional:    false
data:
 Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
 Medium:     
 SizeLimit:  &lt;unset&gt;
 Events:
 Type    Reason            Age   From            Message
  ----    ------            ----  ----            -------
 Normal  SuccessfulCreate  2m5s  job-controller  Created pod: database-import-9tsjw
 Normal  SuccessfulCreate  119s  job-controller  Created pod: database-import-g68ld
 Normal  SuccessfulCreate  109s  job-controller  Created pod: database-import-8cx6v
 Normal  SuccessfulCreate  69s   job-controller  Created pod: database-import-tnjnh
</code></pre>

Stefano Maglione
<p>The command to see the log of an init container ran in a job is:</p>

<pre><code>kubectl logs -f &lt;pod name&gt;  -c &lt;initContainer name&gt;
</code></pre>
