Docker Community Forums

Share and learn in the Docker community.

Unable to start postgres with volume mount

I am not able to start postgres in my laptop inside docker container using below command:-
docker run -d --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -e PGDATA=/var/lib/postgresql/data/pgdata -v d:/custom/mount:/var/lib/postgresql/data postgres
Getting below error:-
fixing permissions on existing directory /var/lib/postgresql/data/pgdata … ok
creating subdirectories … ok
selecting dynamic shared memory implementation … posix
selecting default max_connections … 20
selecting default shared_buffers … 400kB
selecting default time zone … Etc/UTC
creating configuration files … ok
2020-03-26 07:58:11.184 UTC [81] FATAL: data directory “/var/lib/postgresql/data/pgdata” has wrong ownership
2020-03-26 07:58:11.184 UTC [81] HINT: The server must be started by the user that owns the data directory.
child process exited with exit code 1
initdb: removing contents of data directory “/var/lib/postgresql/data/pgdata”
running bootstrap script …

Please help…

Finally, if your issue has not been addressed elsewhere, running:

  • :whale: :arrow_right: Settings :arrow_right: Diagnose & Feedback :arrow_right: Open Issues.

This forum is not an official product support or issue reporting channel.

Hello skumar58,

Try to create the volume manually first, then run your container by mounting it to the volume.

Best Regards,
Fouscou