<p>I am using minikube on Ubuntu 18 and running a kubernetes job that should simply mount a dir and output something to a file using this yaml file </p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: pi13
spec:
  template:
    spec:
      containers:
      - name: pi
        image: perl
        command: ["/bin/echo"]
        args: ["1 &gt;&gt; /data/text12.txt"]
        volumeMounts:
        - mountPath: /data
          name: data
      volumes:
        - name: data
          hostPath:
            path: /home/user/data
      restartPolicy: Never
  backoffLimit: 1
</code></pre>

<p>It runs fine and gives this output in the dashboard </p>

<blockquote>
  <p>1 >> /data/shai12.txt</p>
</blockquote>

<p>But writes nothing to the file (I try to read it on the host after the run is completed but nothing happens) </p>

<p>What am i missing here? </p>

thebeancounter
<p>Your job should like like this:</p>

<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: pi13
spec:
  template:
    spec:
      containers:
      - name: pi
        image: perl
        command: [ "sh", "-c"]
        args: ["echo 1 &gt;&gt; /data/text12.txt"]
        volumeMounts:
        - mountPath: /data
          name: data
      volumes:
        - name: data
          hostPath:
            path: /tmp/data
      restartPolicy: Never
  backoffLimit: 1
</code></pre>

<p>In your case you pass whole <code>1 &gt;&gt; /data/text12.txt</code> to echo command and as results it prints <code>1 &gt;&gt; /data/text12.txt</code> what you can check in job logs.</p>

<p><code>hostPath</code> creates directory <code>/data</code>, so this is why you found it.</p>

<p>I hope it helps.</p>
