Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I'm having issues accessing my postgres db from my remote machine. I'm running docker-compose (django and postgres) from a digitalOcean droplet, so I need to be able to access the db from my mac.

I thought the below would work based on the outline of environment usage in docker-compose. Any help would be appreciated.

db:
  image: postgres
  ports:
    - "5555:5555"
  environment:
    - POSTGRES_PASSWORD=mysecretpassword
    - POSTGRES_USER=postgres
web:
  build: .
  command: python manage.py runserver 0.0.0.0:8000
  volumes:
    - .:/code
  ports:
    - "8000:8000"
  links:
    - db

I'm trying to access the postgres db from pgadmin3 on port 5555, user:postgres, pass:mysecretpassword.

share|improve this question
    
is pgadmin3 running on – Greg Apr 6 '15 at 11:55
    
Did you make postgres listen on port 5555 (does postgresql.conf have port set to 5555 and listen set to *) in container db? If you did, can you 'docker exec -it db bash' and once in, 'psql -p 5555 -h 127.0.0.1 -U postgres' ? – Greg Apr 6 '15 at 12:01
    
Did you figure this out? – aralar Apr 21 '15 at 14:14
    
what's your postgres image downloaded? – kikicarbonell Jun 11 '15 at 17:57
    
Same problem here. It looks like the environment variable POSTGRES_PASSWORD is being ignored. – jap1968 Sep 30 '16 at 12:15

Postgres uses port 5432 by default. You can map the 5432 port within the container to the host post of 5555 with a colon (as shown below).

db:
  image: postgres
  ports:
    - "5555:5432"
  environment:
    - POSTGRES_PASSWORD=mysecretpassword
    - POSTGRES_USER=postgres

You're database is now accessible via port 5555.

I haven't used pgAdmin, but with psql the database can be accessed with...

psql -U postgres -h <your ip> -p 5555
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.