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

  • How to get a list of images on docker registry v2
  • Building images on docker
  • SSH directly into a docker container
  • When would I use `--interactive` without `--tty` in a Docker container?
  • Installing PostgreSQL within a docker container
  • error while starting Titan database using docker
  • 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.

  • Docker Fluentd Logging Driver For multiline
  • Is there a Docker Swarm dashboard like Kubernetes' dashboard/ui? [closed]
  • Mule 3.7 insufficient memory for JVM
  • How are docker-machine certs used?
  • No space left on device when pulling an image
  • Access Docker Container App from phone on local network
  • 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.