<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>

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

<p>First of all, there is no need to run the <code>docker run</code> command inside the pod :). A <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment" rel="nofollow noreferrer">spec file</a> (yaml) should be written for the pod and kubernetes will run the container in the pod using docker for you. Ideally, you don't need to run <code>docker</code> commands when using kubernetes (unless you are debugging docker-related issues).</p>

<p><a href="https://kubernetes.io/docs/reference/kubectl/docker-cli-to-kubectl/" rel="nofollow noreferrer">This link</a> has useful <code>kubectl</code> commands for docker users.</p>

<p>If you are used to <code>docker-compose</code>, refer <code>Kompose</code> to go from <code>docker-compose</code> to kubernetes:</p>

<ul>
<li><a href="https://github.com/kubernetes/kompose" rel="nofollow noreferrer">https://github.com/kubernetes/kompose</a></li>
<li><a href="http://kompose.io" rel="nofollow noreferrer">http://kompose.io</a></li>
</ul>

<p>Some options to mount a directory on the host as a volume inside the container in kubernetes:</p>

<ul>
<li><a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">hostPath</a></li>
<li><a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir" rel="nofollow noreferrer">emptyDir</a></li>
<li><a href="https://kubernetes.io/docs/concepts/storage/volumes/#configmap" rel="nofollow noreferrer">configMap</a></li>
</ul>
