<p>I have a pod running python image as 199 user. My code app.py is place in <code>/tmp/</code> directory, Now when I run copy command to replace the running <code>app.py</code> then the command simply fails with file exists error.</p>

<p><a href="https://i.stack.imgur.com/JND3c.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JND3c.png" alt="enter image description here"></a></p>

prashant
<p>Please try to use the <code>--no-preserve=true</code> flag with <code>kubectl cp</code> command. It will pass <code>--no-same-owner</code> and <code>--no-same-permissions</code> flags to the <code>tar</code> utility while extracting the copied file in the container.</p>

<p>GNU <a href="https://www.gnu.org/software/tar/manual/html_node/Dealing-with-Old-Files.html" rel="nofollow noreferrer"><code>tar</code> manual</a> suggests to use <code>--skip-old-files</code> or <code>--overwrite</code> flag to <code>tar --extract</code> command, to avoid error message you encountered, but to my knowledge, there is no way to add this optional argument to <code>kubectl cp</code>. </p>
