<p>I'm trying to copy a file from a container to my mac and I also look into this question <a href="https://stackoverflow.com/questions/52407277/how-to-copy-files-from-kubernetes-pods-to-local-system">How to copy files from kubernetes Pods to local system</a> but didn’t help</p>
<p>at first, I tried</p>
<pre><code>kubectl cp -n company -c company-web-falcon company/company-web-falcon-bb86d79cf-6jcqq:/etc/identity/ca/security-ca.pem /etc/identity/ca/security-ca.pem
</code></pre>
<p>which resulted in this error</p>
<pre><code>tar: Removing leading `/' from member names
</code></pre>
<p>So I tried this</p>
<pre><code>kubectl cp -n company -c company-web-falcon company/company-web-falcon-bb86d79cf-6jcqq:/etc/identity/ca/security-ca.pem /etc/identity/ca/security-ca.pem  .
</code></pre>
<p>which resulted in this error</p>
<pre><code>    error: source and destination are required
</code></pre>
<p>how should I fix it?</p>

Hard Worker
<p>You can copy the file with the following command <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#cp" rel="nofollow noreferrer">kubectl cp</a></p>
<ul>
<li>Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace</li>
</ul>
<pre class="lang-bash prettyprint-override"><code>kubectl cp /tmp/foo_dir &lt;some-pod&gt;:/tmp/bar_dir
</code></pre>
<ul>
<li>Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container</li>
</ul>
<pre class="lang-bash prettyprint-override"><code>kubectl cp /tmp/foo &lt;some-pod&gt;:/tmp/bar -c &lt;specific-container&gt;
</code></pre>
<ul>
<li>Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace</li>
</ul>
<pre class="lang-bash prettyprint-override"><code>kubectl cp /tmp/foo &lt;some-namespace&gt;/&lt;some-pod&gt;:/tmp/bar
</code></pre>
<ul>
<li>Copy /tmp/foo from a remote pod to /tmp/bar locally</li>
</ul>
<pre class="lang-bash prettyprint-override"><code>kubectl cp &lt;some-namespace&gt;/&lt;some-pod&gt;:/tmp/foo /tmp/bar
</code></pre>
<p>As for the warning that you receive, you can get more details in the github <a href="https://github.com/kubernetes/kubernetes/issues/58692" rel="nofollow noreferrer">issues</a>
There are multiple accepted explanations. The best one is the following</p>
<p>You move the wanted file to the working dir in the pod (the directory which is automatically opened, when you open bash on it) -</p>
<pre class="lang-bash prettyprint-override"><code>user@podname:/usr/src# ls data.txt
data.txt
</code></pre>
<p>In this case it is - /usr/src folder.</p>
<p>Then in the local bash terminal -</p>
<pre class="lang-bash prettyprint-override"><code>user@local:~$ kubectl cp podname:data.txt data.txt
user@local:~$ ls data.txt
data.txt
</code></pre>
