Skip to content

Cant connect to DB from host #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andjarnic opened this issue Jul 14, 2016 · 3 comments
Closed

Cant connect to DB from host #176

andjarnic opened this issue Jul 14, 2016 · 3 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@andjarnic
Copy link

Hi all,

I have built the docker image, ran it, and connect to it to verify it works. I can use psql in the instance shell and create database, etc. That all seems to work fine.

What I cant do is connect from my Mac host to the running container DB. I have used the IP from docker inspect, the -p 5432:5432 is in my run command, etc. In fact, I cant even ping the container ip listed in inspect.

Ultimately I want to a) connect via my host to the DB and b) have a separate container connect to the DB container.

I am using the latest native docker on Mac now, no longer boot2docker. Is there something special needed to make this work?

@JacobJohansen
Copy link

I think some of the parameters changed somewhere along the way
docker run --name NAME --expose 5432 -p 5432:5432 -e POSTGRES_USER=dbuser -e POSTGRES_DB=dbname -e POSTGRES_PASSWORD=password -d postgres

@jcrben
Copy link

jcrben commented Oct 22, 2017

This worked for me - note that I used a different port number because I have postgres running locally on my Mac:
docker run -it --rm -p 5433:5432 -e POSTGRES_PASSWORD=12345 -e POSTGRES_USER=bob postgres:latest

psql -p 5433 -h localhost -U postgres

Also, problems can crop up for other reasons such a volume hanging around - see e.g. #203 (comment)

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Apr 24, 2018
@wglambert
Copy link

Looks like this issue was resolved so I'm going to prune.
If you believe this to be in error then let me know and I'll re-open it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

4 participants