title: Docker: postgres volume location and permissions
body: <p>I have the following docker-compose file</p>
  <pre><code>version: '3.7'
  
  volumes:
    postgres-data:
  
  services:
   postgres:
      environment:
      - POSTGRES_PASSWORD=mypwd
      - POSTGRES_USER=randomuser
      image: 'postgres:14'
      restart: always
      volumes:
       - './postgres-data:/var/lib/postgresql/data'
  </code></pre>
  <p>I seem to have multiple issues regarding the volume:</p>
  <ul>
  <li>A folder named <code>postgres-data</code> is created in the docker-compose file location when I run <code>up</code>, though it seems that for other images, they get placed in the <code>/var/lib/docker/volumes</code> folder instead (without creating such a folder). Is this expected ? Is it a good practice to have the volume folder created in the same location as the docker-compose file, instead of the <code>/var/lib/docker/volumes</code> folder ?</li>
  <li>This folder has weird ownership, I can't get into it as my current user (though I am in the docker group).</li>
  </ul>
  <p>I tried reading the <a href="https://github.com/docker-library/docs/blob/master/postgres/README.md" rel="nofollow noreferrer">image documentation</a>, especially the &quot;Arbitrary --user Notes&quot;, but didn't understand what to do with it. I also tried not setting the POSTGRES_USER (which then defaults to postgres), but the result is the same.</p>
  <p>What's the correct way to create a volume using this image ?</p>