<p>I'm trying to deploy a react app on my local machine with docker-desktop and its kubernetes cluster with <strong>bitnami apache helm chart</strong>.<br/>
I'm following this <a href="https://docs.bitnami.com/tutorials/deploy-react-application-kubernetes-helm/" rel="nofollow noreferrer">this tutorial</a>.<br/>
The tutorial makes you publish the image on a public repo (step 2) and I don't want to do that. It is indeed possible to pass the app files through a persistent volume claim.<br/>
This is described in the <a href="https://docs.bitnami.com/tutorials/deploy-static-content-apache-kubernetes/" rel="nofollow noreferrer">following tutorial</a>.</p>
<p>Step 2 of this second tutorial lets you create a pod pointing to a PVC and then asks you to copy the app files there by using command <br/></p>
<pre><code>kubectl cp /myapp/* apache-data-pod:/data/
</code></pre>
<p>My issues:</p>
<ol>
<li>I cannot use the * wildcard or else I get an error. To avoid this I just run</li>
</ol>
<blockquote>
<p>kubectl cp . apache-data-pod:/data/
<br/></p>
</blockquote>
<ol start="2">
<li>This instruction copies the files in the pod but it creates another data folder in the already existing data folder in the pod filesystem<br/>
After this command my pod filesystem looks like this
<a href="https://i.stack.imgur.com/PqBdm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PqBdm.png" alt="enter image description here" /></a>
I tried executing</li>
</ol>
<blockquote>
<p>kubectl cp . apache-data-pod:/</p>
</blockquote>
<p>But this copies the file in the root of the pod filesystem at the same location where first data folder is.<br/></p>
<p>I need to copy the data directly in &lt;my_pod&gt;:/data/.
How can I achieve such behaviour?</p>
<p>Regards</p>

Sergio Arrighi
<p>**Use the full path in the command as mentioned below to copy local files to POD : *</p>
<pre><code>kubectl cp apache-pod:/var/www/html/index.html /tmp
</code></pre>
<p>*<em>If there are multiple containers on the POD, Use the below syntax to copy a file from local to pod:</em></p>
<pre><code>kubectl cp /&lt;path-to-your-file&gt;/&lt;file-name&gt; &lt;pod-name&gt;:&lt;fully-qualified-file-name&gt; -c &lt;container-name&gt;
</code></pre>
<p><strong>Points to remember :</strong></p>
<ol>
<li>While referring to the file path on the POD. It is always relative to the WORKDIR you have defined on your image.</li>
<li>Unlike Linux, the base directory does not always start from the /  workdir is the base directory</li>
<li>When you have multiple containers on the POD you need to specify the container to use with the copy operation using -c parameter</li>
</ol>
<p><strong>Quick Example of kubectl cp :</strong> Here is the command to copy the index.html file from the POD’s /var/www/html  to the local /tmp directory.</p>
<p>No need to mention the full path, when the doc root is the workdir or the default directory of the image.</p>
<pre><code>kubectl cp apache-pod:index.html /tmp
</code></pre>
<p>To make it less confusing, you can always write the full path like this</p>
<pre><code>kubectl cp apache-pod:/var/www/html/index.html /tmp
</code></pre>
<p>*Also refer to this <a href="https://stackoverflow.com/questions/52407277/how-to-copy-files-from-kubernetes-pods-to-local-system">stack question</a> for more information.</p>
