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.

- 681
- 10
- 19
2 Answers
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. example.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.

- 23,933
- 14
- 88
- 109

- 1,511
- 2
- 20
- 29
-
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
It's also possible using ssh tunnel.
dokku postgres:list
for all postgres instances
dokku postgres:info DBNAME
checks exposed ports (if it has) and credentials
- Use
DNS
for credentials, as mentioned in previous answer Exposed ports
- check whether app looks to the internetInternal IP
- host ip, that can be used over ssh
In your postgres client choose an option with ssh tunnel or forward port using putty or etc.

- 61
- 1
- 1