<p>I am building a Podman image for Openshift, and have an issue with permissions.</p>
<p>Following <a href="https://cloud.redhat.com/blog/jupyter-on-openshift-part-6-running-as-an-assigned-user-id" rel="nofollow noreferrer">this guide</a>, and because Openshift assigns a random UID and a GID &quot;0&quot; when running containers, I try to <code>chmod</code> the <code>/etc/passwd</code> to be writable by its group and add my Openshift user in it at runtime; but it seems that I can't always <code>chmod</code> that <code>/etc/passwd</code> file.</p>
<p>Minimal Dockerfile:</p>
<pre><code>FROM ubuntu:20.04

USER root

RUN ls -l /etc/passwd
RUN chmod g+w /etc/passwd
RUN ls -l /etc/passwd
</code></pre>
<p>When building (<code>sudo podman build . -t test-image</code>), I see the correct rights on <code>/etc/passwd</code>:</p>
<pre><code>STEP 1: FROM ubuntu:20.04
STEP 2: USER root
--&gt; Using cache 2cb48e4f8eed907e057017011e20ddc47ec8f152bb7afe34ecf6be23413cd08b
STEP 3: RUN ls -l /etc/passwd
-rw-r--r--. 1 root root 926 Sep 21 16:48 /etc/passwd
     ^
     ^
     ^
79f60398d64ece1b413fd904681ad5fd0725bae4b283abce7b7a9ea017d4ebe7
STEP 4: RUN chmod g+w /etc/passwd
6ed13401ab693dbc362ec90b9c3767c1cd2244074ca4e92bd1b31b72b3e80868
STEP 5: RUN ls -l /etc/passwd
-rw-rw-r--. 1 root root 926 Sep 21 16:48 /etc/passwd
     ^
     ^
     ^
STEP 6: COMMIT test
d667b2c05818b5af3c9db85a5e7179c8e7b1c21281e31c34a871e97268716f39
</code></pre>
<p>When I run my container with <code>root</code> user, no issue:</p>
<pre><code>[user@server]$ sudo podman run -it test-image /bin/bash
root@295ab7b72a4d:/# ls -l /etc/passwd
-rw-rw-r--. 1 root root 926 Sep 21 16:48 /etc/passwd
     ^
     ^
     ^
</code></pre>
<p>But when I run with a random user, <code>/etc/passwd</code> rights aren't changed anymore...</p>
<pre><code>[user@server]$ sudo podman run -it -u 1000701200:0 test-image /bin/bash
1000701200@a63d9bf9f53a:/$ ls -l /etc/passwd
-rw-r--r--. 1 root root 977 Oct 19 08:51 /etc/passwd
     ^
     ^
     ^
</code></pre>
<p>Why do the rights on <code>/etc/passwd</code> depend on the user who run the container?</p>
<p>Thanks in advance.</p>
<p>EDIT 1: This is not the case with a random file I create, it works as expected. So there is something special about the <code>/etc/passwd</code> file.</p>

MeanStreet
<p>The podman version was at cause - updating to 3.x version solved the issue.</p>
