0

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'
    services:
      postgresql:
        image: postgres:9.5
        environment:
          - PGDATA=/data 
        ports:
      - '5432:5432'
    volumes:
      - ~/.postgresql:/data
  web:
    build: .
    command: sbt/sbt run
    volumes:
      - .:/app
    ports:
      - '9001:9001'
    depends_on:
      - postgresql

Here's the error I see

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.

1
  • You mean add a User in the existing db? Or write my own Docker Postgres image using the official as a base with the command you referenced. Commented Mar 30, 2016 at 19:08

1 Answer 1

1

The error message is pretty clear. I think the container runs postgres with user postgres which has a uid/gid of 999 (see https://github.com/docker-library/postgres/blob/3f8e9784438c8fe54f831c301a45f4d55f6fa453/9.5/Dockerfile line 5). You need to chown your host data folder to a user with the same uid.

Sign up to request clarification or add additional context in comments.

1 Comment

Oh ok I didn't know about the uid thing, let me try and fix that and get back to you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.