I'm having a hard time finding a way to access Postgres database inside Dokku's contaner (based on docker) from outside of the machine using pgAdmin. Is there a way to do that? Do I need to use a different client? I'm exposing database using dokku postgres:expose
command.
Asked
Active
Viewed 5,599 times
13
![](../../users/profiles/330315.webp)
a_horse_with_no_name
- 440,273
- 77
- 685
- 758
![](../../users/profiles/5517049.webp)
Chris Kraszewski
- 631
- 9
- 19
1 Answers
42
To connect with a pgadmin you can get all the necessary information from the DATABASE_URL.
➜ ~ dokku postgres:info your-database-db
DSN: postgres://postgres:bf8f1cb443c35cd1ae0a58617ef348cd@dokku-postgres-your-database-db:5432/your_database_db
Because dokku have the same foundation as heroku you can extract the information to connect with pg database. The important consideration is that dokku generate a random port for exposure your database. You can get a random port or set any that you want.
[database type]://[username]:[password]@[host]:[port]/[database name]
Exposing the database and getting the real port:
➜ ~ dokku postgres:expose your-database-db
! Service is already started
-----> Service your-database-db exposed on port(s) 17825
Now in your pg admin you will add the next information and hopefully connect without issues.
username: postgres
password: bf8f1cb443c35cd1ae0a58617ef348cd
hostname: Your-Dokku-Host-URL (Ex. domain.com or IP of your dokku server)
port: 17825
Also, if you are running dokku in AWS EC2, for example, you need to allow access to this port on the instance, adding a Custom TCP Rule in the Inbound section of the Security Group this instance is associated with.
Hope it helps.
![](../../users/profiles/675486.webp)
Natan R.
- 5,003
- 1
- 29
- 46
![](../../users/profiles/1060541.webp)
Jorge Najera T
- 1,376
- 2
- 17
- 26
-
In testing this command, I noticed you may need to specify the port you'd like to expose (running dokku version 0.19.6): `dokku postgres:expose your-database-db PORT` – Leo Nov 04 '19 at 04:58