chown has no effect inside docker container

1

1

Core problem
I have some files that are currently owned by 'root':

root@b75277d71d6f:/app/config/jwt# getfacl public.pem
# file: public.pem  
# owner: root  
# group: root  
user::rwx  
group::r-x  
other::r-x   

Now I want to change the owner of this file (using chown):

chown -R application:application public.pem -v  
changed ownership of 'public.pem' from root:root to application:application

Looks good, right? But calling getfacl again reveals that actually nothing changed:

root@b75277d71d6f:/app/config/jwt# getfacl public.pem
# file: public.pem  
# owner: root  
# group: root  
user::rwx  
group::r-x  
other::r-x   

Context (may be relevant): I am working on a web development project (Shopware 6) and got this error when opening the website on localhost:

User Notice: Key file "file:///app/config/jwt/public.pem" permissions are not correct, recommend changing to 600 or 660 instead of 755

I then stumbled upon another user with the same problem. He was able to solve it by changing the ownership to 'application' (link in german: https://forum.shopware.com/discussion/comment/255936#Comment_255936. And that is how I ended up here.

Any help is really appreciated :)

Edit: I found this thread with the same problem: https://askubuntu.com/questions/398767/chown-has-no-effect-even-after-it-claims-it-changed-owner
The proposed solution is to change the owner via the mount command. Sadly I am totally lost in how to achieve this, because I am new to Linux and Docker.

admi22

Posted 2019-10-02T10:04:31.343

Reputation: 11

The last link is not particularly relevant here because permissions inside Docker will be different. What is the output of ls -l /app/config/jwt? chown will not help here, try chmod 600 public.pem – slhck – 2019-10-02T10:43:12.030

You can change the file ownership in the Dockerfile: COPY --chown=newuser:newgroup localfile /path/to/container/file. The file retains its flags from the source file. – xenoid – 2019-10-02T12:03:44.170

@slhck output of ls -l is [...] Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) [...] after applying chmod 600 it is still the same (same behaviour as chown). So it seems like none of these commands actually have an effect. – admi22 – 2019-10-02T13:46:43.320

I ran into this issue this week and still struggling with it. My issue is happened at the building time. It seems that it can reproduce at my ubuntu 19.10 box and the docker hub builds environment. However, the same Dockerfile can work without any problem at an Ubuntu 18.04 on the azure cloud. – Huan – 2020-02-18T04:03:32.660

No answers