title: Postgresql in a Docker Container on Windows: How to persist data to a local windows folder
body: <p>I'm trying to run postgres in a docker container on windows.  I also want keep the data in a windows folder, so I tried this:</p>
  
  <pre><code>mkdir c:\pgdata
  
  PS &gt; docker run --name postgres -v c:\pgdata:/var/lib/postgresql/data -d postgres
  d12af76bed7f8078babc0b6d35710dfc02b12d650904ed53ca95bb99984e9b36
  </code></pre>
  
  <p>This appeared to work, but the container is not running and the log tells a different story:</p>
  
  <pre><code>2019-07-24 23:19:20.861 UTC [77] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
  2019-07-24 23:19:20.861 UTC [77] HINT:  The server must be started by the user that owns the data directory.
  child process exited with exit code 1
  </code></pre>
  
  <p>If I remove the volume option, it starts up fine, but then I don't get my database files persisted where I want them.  What am I doing wrong here?</p>