<p>My current development environment allows for automatic code reload whenever changing a file (i.e <code>nodemon</code> / <code>webpack</code>). However I am setting up a <code>kubernetes</code> (<code>minikube</code>) environment so that I can quickly open 3-4 related services at once. </p>

<p>Everything is working fine, but it is not currently doing the automatic code reload. I tried mounting the volume but there is some conflict with the way <code>docker</code> and <code>virtualbox</code> handles files such that the conflict leads to <a href="https://github.com/docker/docker/issues/15793" rel="noreferrer">file changes from the host not reflected in docker container</a>. (That's not the first link I have that appears related to this problem, it's just the first I found while googling it on another day)...</p>

<p>Anyways, long story short, ppl have trouble getting live reload done in development. I've found the problem literred throughout the interweb with very few solutions. The best solution I would say I found so far is <a href="https://github.com/kubernetes/kubernetes/issues/13776#issuecomment-196325337" rel="noreferrer">This person used tar from the host</a> to sync folders. </p>

<p>However I would like a solution from the container. The reason is that I want to run the script from the container so that the developer doesn't have to run some script on his host computer every time he starts developing in a particular repo.</p>

<p>In order to do this however I need to run rsync from the container to the host machine. And I'm having a surprising lot of trouble figuring out how to write the syntax for that. </p>

<p>Let's pretend my app exists in my container and host respectively as: </p>

<pre><code>/workspace/app # location in container
/Users/terence/workspace/app  # location in host computer
</code></pre>

<p>How do I rsync from the container to the host? I've tried using the <code>172.17.0.17</code> and <code>127.0.0.1</code> to no avail. Not entirely sure if there is a way to do it?</p>

<p>examples I tried:</p>

<pre><code>rsync -av 172.17.0.17:Users/terence/workspace/app /workspace/app
rsync -av 127.0.0.1:Users/terence/workspace/app /workspace/app
</code></pre>

<p>If you're running the rsync from the host (not inside the container), you could use <code>docker cp</code> instead:</p>

<p>e.g., <code>docker cp containerName:/workspace/app Users/terence/workspace/app</code></p>

<p>Could you clarify:<br>
1. are you running the rsync from the host or from inside the container?<br>
If it's from inside the container it'll depend a lot on the <code>--network</code> the container is attached to (i.e., bridged or host) and also the mounted volumes (i.e., when you started up the container did you use -v flag?)</p>

<p><strong>Update</strong>: For rsync to work from within the container you need to expose the host's dir to the container.</p>

<p>As you think of a solution, keep this in mind: <a href="https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-a-data-volume" rel="noreferrer">host dir as a data volume</a></p>

<blockquote>
  <p><strong>Note</strong>: The host directory is, by its nature, host-dependent. For this reason, you can’t mount a host directory from Dockerfile, the VOLUME instruction does not support passing a host-dir, because built images should be portable. A host directory wouldn’t be available on all potential hosts.</p>
</blockquote>
