23

How do I mount a volume writable by a non-root container user? I am ok with either the volume being owned by the non-root user or permissions being set to 777.

Dockerfile:

FROM alpine
RUN adduser -D myuser
USER myuser

Build image:

docker build -t example .

Run image, see /app unwritable 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 can see app is globally readable but only writable by root.

1 Answers1

15

That is not yet supported, and is studied in issue 2259.
That affect other images like docker-java.

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

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • In this case, the volume is a container, so no workaround. :( I'm going to drive it externally, perform volume based actions as root and others as a separate user with -u. Thanks for pointing me to this bug. – Frederick F. Kautz IV Nov 12 '15 at 22:08