docker-postgresql: Wrong owner of mounted data directory

Postgresql expects to be started by the user that owns the data directory. But that doesn’t work when using a mounted volume.

docker run -d --name postgresql --publish 5432:5432 -v /Users/me/db:/var/lib/postgresql sameersbn/postgresql:9.4

Results in:

Starting PostgreSQL server...
LOG:  skipping missing configuration file "/var/lib/postgresql/9.4/main/postgresql.auto.conf"
2015-03-10 16:05:23 UTC [13-2] FATAL:  data directory "/var/lib/postgresql/9.4/main" has wrong ownership
2015-03-10 16:05:23 UTC [13-3] HINT:  The server must be started by the user that owns the data directory.

Somehow the ‘9.4’ directory is created, but not ‘main’ directory in there, throwing above exception.

I’m on OSX using boot2docker.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

@cyberco I add the "pg_xlog/000000010000000000000001": No such file or directory error when having the postgresql volumes on a Vagrant shared folder (Windows host). Moving the volume location to a normal folder did solve the issue.

See http://serverfault.com/questions/699966/fail-to-start-postgresql-when-used-with-vagrant