Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

docker non-root user volumes creates directories the non-root user has no permission to view that

I can run docker run ... as a non-root user (let’s call it pg) and it works, but the issue is something like this:

docker run -d -v /home/pg/pg/:/var/lib/postgresql/data/ postgres

This creates a directory for volume like this:

drwx------ 19        70 root      4096 Jun 19 20:53 pg/

in which case, the pg user cannot access to /home/pg/pg directory:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

pg@server:/home/pg/$ ll pg/
ls: cannot open directory 'pg/': Permission denied

I need this because I created a new user for pg and I told developer to use this user instead of root.

Besides granting sudo access to pg (which makes no sense for creating different users for different projects) or even chowning the directory to pg:pg, are there any other ways?

>Solution :

are there any other ways?

Give access to others to the dir.

chmod 777 /home/pg/pg
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading