title: Creating/generating files in a mounted volume on docker container own to regular user and not to root
body: <p>The <strong>Problem</strong>: can't generate/create files on mounted volumes in docker that is not own by root. Throwing permission denied errors when I create and push my user to docker-compose as well.</p>
  <p><strong>Scenario</strong>:</p>
  <pre><code>version: '3.4'
  services:
    app:
      image: ubuntu:latest
      command: /home/john/clone_repository_and_generate_reports.sh 
      volumes:
        - &quot;/home/john/:/home/john/&quot;
      environment:
        - NODE_ENV=production
      env_file:
        - ./.config.env
  </code></pre>
  <ul>
  <li><p>My <code>docker-compose.yml</code> file calls to simple bash script that clones a github repository and generate different reports in python, In addition I want this data to be accessible and persistent to user <code>john</code>, unfortunately the the saved files are on <code>root</code> only.</p>
  </li>
  <li><p>If Im adding on Dockerfile additional user <code>RUN addgroup -S developer &amp;&amp; adduser -S john -G developer</code> It gets permissions issue accessing to this mounted volume with <code>user: john</code> attribute on docker-compose.yml file</p>
  </li>
  </ul>
  <p><strong>Expected behaviour</strong>: cloned github repository and generated files owned by <code>john</code> and <strong>not</strong> by <code>root</code>.</p>
  <p>What is the right approach dealing with permission issue on docker?
  How can I save these files under <code>john</code> user on this mounted volume?</p>