How to write to a volume container as non-root in docker?

How to mount a volume writable by a non-root user? I am fine with a volume owned by a non-root user, or with permissions set to 777.

Dockerfile:

FROM alpine RUN adduser -D myuser USER myuser 

Assembly image:

 docker build -t example . 

Run image, see / application that cannot be written by user

 % docker run -i -t -v myapp:/app example /bin/sh / $ whoami myuser / $ ls -lha / | grep app drwxr-xr-x 2 root root 4.0K Nov 12 21:01 app / $ 

We see that the application is readable globally, but only writable by root.

+5
source share
1 answer

This is not yet supported and is being studied in issue 2259 .
This affects other images like docker-java .

Basically, you should chown and copy (with the right user) your data in a volume , which is not very convenient.

+4
source

Source: https://habr.com/ru/post/1235833/


All Articles