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

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:

  • Docker - run two processes in single container
  • Import AMI image as Docker image
  • Jhipster CI (Jenkins 2 + Sonarqube) -> Memory Heap
  • dante-sever fail to bind ip by interface name in docker container
  • Starting a process in the Dockerfile
  • What are the best practices for tagging Docker Hub versions
  • 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.

  • linux container display wrong information
  • Change the owner of a file in a running Docker container with an attached volume in Windows
  • Is it possible to run multiple docker/lxc/lxd container based on one base container?
  • Bluemix create container group linking to another container
  • COREOS error on Bare Metal Server (unix socket /var/run/docker.sock does not exist)
  • Not able to run Meteor application in Docker container because of couldn't run ps ax error
  • One Solution collect form web for “How do I write to a volume container as non-root in docker?”

    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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.