5

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.

5
  • is pgadmin3 running on Commented Apr 6, 2015 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' ? Commented Apr 6, 2015 at 12:01
  • Did you figure this out? Commented Apr 21, 2015 at 14:14
  • what's your postgres image downloaded? Commented Jun 11, 2015 at 17:57
  • Same problem here. It looks like the environment variable POSTGRES_PASSWORD is being ignored. Commented Sep 30, 2016 at 12:15

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

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.