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

2 Answers 2

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/

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

1 Comment

Thanks @Jomaar for the helpful pointer & references. I ended up doing a chmod on the file & it worked.
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

Comments

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.