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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With