title: Docker-compose and named volume permission denied
body: <p>There is docker-compose that uses base Dockerfile created image for application.</p>
  <p>Dockerfile looks similar to below. Some lines are omitted for reason.</p>
  <pre><code>FROM ubuntu:18.04
  
  RUN set -e -x ;\
      apt-get -y update ;\
      apt-get -y upgrade ;
  
  ...
  
  USER service
  </code></pre>
  <p>When using this image in docker-compose and adding named volume to service, folder in named volume is not accessible, with message <code>Permission denied</code>. Part from docker-compose looks as below.</p>
  <pre class="lang-yml prettyprint-override"><code>version: &quot;3.1&quot;
      services:
          myapp:
              image: myappimage
              command:
                  - /myapp
              ports:
                  - 12345:1234
              volumes:
                  - logs-folder:/var/log/myapp
  
  volumes:
      logs-folder:
  </code></pre>
  <p>My assumption was that <code>USER service</code> line is issue, which I confirmed by setting <code>user: root</code> in myapp service.</p>
  <p>Now, question is next. I would like to avoid manually creating volume and setting permissions. I would like it to be automated using docker-compose.</p>
  <p>Is this possible and if yes, how can this be done?</p>