Docker Community Forums

Share and learn in the Docker community.

Quickstart: Compose and Rails - postgres permissions error

I’m following the https://docs.docker.com/compose/rails/ Compose and Rails quickstart document, without modification, using Docker Desktop for Windows.

I am able to get through the docker-compose build step successfully, and then modify the app’s config/database.yml. However, when I then run docker-compose up I get:

$ docker-compose up
Recreating postgres ... done
Recreating rails5_web_1 ... done
Attaching to postgres, rails5_web_1
postgres | The files belonging to this database system will be owned by user "postgres".
postgres | This user must also own the server process.
postgres |
postgres | The database cluster will be initialized with locale "en_US.utf8".
postgres | The default database encoding has accordingly been set to "UTF8".
postgres | The default text search configuration will be set to "english".
postgres |
postgres | Data page checksums are disabled.
postgres |
postgres | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres | creating subdirectories ... ok
postgres | selecting default max_connections ... 20
postgres | selecting default shared_buffers ... 400kB
postgres | selecting dynamic shared memory implementation ... posix
postgres | creating configuration files ... ok
postgres | running bootstrap script ... 2019-04-03 13:13:27.844 UTC [77] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
postgres | 2019-04-03 13:13:27.844 UTC [77] HINT:  The server must be started by the user that owns the data directory.
postgres | child process exited with exit code 1
postgres | initdb: removing contents of data directory "/var/lib/postgresql/data"
postgres exited with code 1

I’ve confirmed that the postgres user owns the erroring /data directory. I’m baffled as I assume many people have run through that Quickstart with no issues. I’m not doing anything unique as far as I can tell.

Help & suggestions very welcome!