Gotcha. I think I have a basic idea on how to do that. Seems like there are two parts here: 1) Configuring my Postgres service to be accessible from the IP pertaining to the Redash service. 2) Telling Redash to connect to the database at the port the Postgres is being hosted at.
Here’s my current working understanding on how to this is done.
- Configuring the Postgres service to be accessible to Redash means enabling remote connections to the Postgres service as well as exposing a certain port on it.
So I could do something like this for configuring my database service that my Django app uses.
command: "postgres -c config_file=etc/public_ip_ps.conf"
My understanding is that the ports definition above “5433:5432” is saying whenever the local machine connects to port 5433, it is communicating with the port 5432 in the Docker container pertaining to the Postgres database. Additionally, the POSTGRES_PASSWORD: helloworld tells the service to create the default user “postgres” with the password “helloworld” so that a specific user can login to this Postgres service from the outside.
command: “postgres -c config_file=etc/public_ip_ps.conf”
Is needed for configuring a custom Postgres config file. This file right now just has one line in it:
listen_addresses = '*''
So that the Postgres service is configured to receive communication from any IP address. This file is in a directory that gets bind-mounted.
- I’m a bit lost on this part. Not sure how to tell Redash to connect to the Postgres service here exactly. The Redash docker-compose.yml file also seems to make it’s on database service, so I’m not sure how to tell Redash to connect to the Postgres service associated with my Django app.
For instance, an an older example of this seems to recommend to do this by using the
links: definition. Another example from StackOverflow also recommends this. However, it seems that the
links configuration is deprecated, at least according to the official Docker reference page. Here, Docker recommends using user-defined networks instead.