0

I am trying to use the data directory from a preexisting database & bring up a new postgres docker container (same version 9.5) with its '/var/lib/postgresql/data' bind mounted to the data directory.

I find that even though i am able to bring up the container & use psql within the container to connect to it, external connections fail with invalid password. This despite me setting the POSTGRES_USER, POSTGRES_DB & POSTGRES_PASSWORD environment variables.

Is there a way to make this work? I also tried this method but ran into permission error,

"sh: 1: /usr/local/bin/init.sh: Permission denied"

Thanks

lmk
  • 654
  • 5
  • 21

2 Answers2

1

This happends when your user/group id does not match the file owner. You should run your docker with --user

please have a look to Arbitrary --user Notes of https://hub.docker.com/_/postgres

Hope that will help you to fix your problem.

For composer look at https://docs.docker.com/compose/reference/run/

Jomaar
  • 84
  • 9
  • Thanks @Jomaar for the helpful pointer & references. I ended up doing a chmod on the file & it worked. – lmk Jul 01 '20 at 01:57
0

OK i figured out the way to do this & it turns out to be very simple. All i did was,

  • Add a script & copy it into docker-entrypoint-initdb.d in my Dockerfile
  • In the script i had a loop that was waiting for the db to be up & running before resetting the superuser password & privileges.

Thanks

lmk
  • 654
  • 5
  • 21