Docker / Postgres: Mounting an existing database within a dockerized Postgresql

So I’m having a problem mounting an existing set of data for Docker Postgres that I cannot figure out for the life of me. Here’s my docker compose file.

version: '2'
        image: postgres:9.5
          - PGDATA=/data 
      - '5432:5432'
      - ~/.postgresql:/data
    build: .
    command: sbt/sbt run
      - .:/app
      - '9001:9001'
      - postgresql

Here’s the error I see

  • Docker set read timeout for push
  • Remote Debugging with XDebug from inside a Docker Container does not work
  • Docker : Could not resolve host: - for go get ./
  • Translate docker run command to docker compose
  • Spark in docker parquet error No predefined schema found
  • How to copy docker images from one host to another?
  • ostgresql_1 | FATAL:  data directory "/data" has wrong ownership
    postgresql_1 | HINT:  The server must be started by the user that owns the data directory.

    Does anyone have any clue how to fix it? Thank you

    PS I am using Docker Machine through OSX if that makes a difference in this problem.

  • Why https is forced?
  • gcloud preview app setup-managed-vms gives errors - 500 Server Error: Internal Server Error
  • Spring can't connect to docker selenium container to run capybara via rspec
  • Chronos in Docker - jobs stuck as 'queued'
  • How can I start a Docker container on boot in OS X?
  • Docker swarm for usb devices
  • One Solution collect form web for “Docker / Postgres: Mounting an existing database within a dockerized Postgresql”

    The error message is pretty clear. I think the container runs postgres with user postgres which has a uid/gid of 999 (see line 5). You need to chown your host data folder to a user with the same uid.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.