title: Docker compose permission denied with volume
body: <p>I have the following <code>docker-compose</code> file:</p>
  <pre class="lang-yaml prettyprint-override"><code>version: &quot;3.8&quot;
  
  services:
    api:
      image: myuser/myimage
      volumes:
        - static_volume:/app/static
        - /home/deployer/config_files/gunicorn.py:/app/gunicorn.py
        - /home/deployer/log_files:/app/log_files
      env_file:
        - /home/deployer/config_files/api.env
      expose:
        - 8000
  
    nginx:
      image: myuser/nginximage
      volumes:
        - static_volume:/app/static
        - /home/deployer/config_files/nginx.conf:/etc/nginx/conf.d/nginx.conf
      ports:
        - 80:80
      depends_on:
        - api
  
  volumes:
    static_volume:
  </code></pre>
  <p>The <code>api</code> service was built using the following docker file (summarized to reduce size):</p>
  <pre><code>FROM python:3.9.1
  
  WORKDIR /app
  
  # Copy code etc into container
  COPY ./api/ .
  COPY entrypoint.sh .
  
  # create static and log files directories
  RUN mkdir static
  RUN mkdir log_files
  
  # create non root user, change ownership of all files, switch to this user
  RUN adduser --system --group appuser
  RUN chown -R appuser:appuser /app
  USER appuser
  
  CMD [ &quot;/app/entrypoint.sh&quot; ]
  </code></pre>
  <p>If I remove <code>/home/deployer/log_files:/app/log_files</code> from the compose file everything works correctly. However I am trying to use that log files directory for <code>gunicorn</code> to use for log files. Including that line results in the following error when <code>docker-compose up</code>:</p>
  <p><code>Error: Error: '/app/log_files/gunicorn_error.log' isn't writable [PermissionError(13, 'Permission denied')]</code></p>
  <p>On the linux host I am running <code>docker-compose up</code> with the user named <code>deployer</code>. Inside the container as per the Dockerfile I created a user called <code>appuser</code>. I'm guessing this is related to the issue but I'm not sure.</p>
  <p>Basically all I'm trying to do is to have log files inside the container be accessible outside the container so that they persist even if the server is restarted.</p>