Is it possible to login into the postgres database inside the docker using navicat?


(Ova Light) #1

Providing normal info and port 5432/5433 doesn’t seem to work out. Is anyone else using navicat for discourse ??


(Jens Maier) #2

You can expose the PostgreSQL server by adjusting your app.yml:

## which TCP/IP ports should this container expose?
expose:
  - "80:80"   # fwd host port 80   to container port 80 (http)
  - "2222:22" # fwd host port 2222 to container port 22 (ssh)
  - "5432:5432" # <-- add this line

The database shouldn’t be exposed to the internet, however. Expose it under a random non-default port, firewall it to restrict access to your workstation and or use strong passwords.


(Ova Light) #3

seems like the password authentication fails for user postgres. we change that with passwd postgres in the docker image right ? That’s what I did at least


(Jens Maier) #4

No. You need to do this:

  • Enter the container.
  • su - postgres
  • psql -d postgres -c "ALTER USER postgres WITH PASSWORD '<new password>';"

By default, PostgreSQL uses peer authentication for local connections. It uses a feature of Linux whereby it can get the user that initiated the incoming connection, but this only works when the connection was made through the loopback-device (i.e. 127.0.0.1) or a UNIX socket.

When you’re connecting from a remote computer through the TCP socket, peer authentication isn’t available and the Discourse docker container is configured to have PostgreSQL fall back to MD5 authentication. This uses password hashes stored in the database itself, so these passwords are different from the system user passwords, hence passwd postgres, which changes the system login password, doesn’t affect Postgres.


Externally connect to container's database
Docker install mac, fails to update app.yml
(Frank Fang) #5

Do I need to ./launcher rebuild app after ALTER password?