<p>I have a docker image that uses a volume to write files: </p>

<pre><code>docker run --rm -v /home/dir:/out/ image:cli args
</code></pre>

<p>when I try to run this inside a pod the container exit normally but no file is written. </p>

<p>I don't get it. </p>

<p>The container throw errors if it does not find the volume, for example if I run it without the <code>-v</code> option it throws: </p>

<pre><code>Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path '/out/file.txt'.
</code></pre>

<p>But I don't have any error from the container. 
It finishes like it wrote files, but files do not exist.</p>

<p>I'm quite new to Kubernetes but this is getting me crazy. </p>

<p>Does kubernetes prevent files from being written? or am I missing something obvious?  </p>

<p>The whole Kubernetes context is managed by GCP composer-airflow, if it helps...</p>

<pre><code>docker -v: Docker version 17.03.2-ce, build f5ec1e2
</code></pre>

donkino
<p>If you want to have that behavior in Kubernetes you can use a <a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer"><code>hostPath</code></a> volume.</p>

<p>Essentially you specify it in your pod spec and then the volume is mounted on the node where your pod runs and then the file should be there in the node after the pod exits.</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test-pd
spec:
  containers:
  - image: image:cli
    name: test-container
    volumeMounts:
    - mountPath: /home/dir
      name: test-volume
  volumes:
  - name: test-volume
    hostPath:
      path: /out
      type: Directory
</code></pre>
