Hi all, first time poster so apologies if I haven't found this solution somewhere else already.
I have both Metabase and Postgresql running successfully in separate docker containers, both on my local machine.
Metabase cannot connect to the Postgresql docker. I have connections via DBeaver and QGIS to Postgresql that are working fine. Both psql and nc are connecting to postgresql fine both via localhost and 0.0.0.0 host names.
The error I am getting is: "Hmm, we couldn't connect to the database. Make sure your Host and Port settings are correct"
Does anyone know of a limitation connecting 2 docker containers in the method I am attempting?
Yes - as I stated above: I have connections via DBeaver and QGIS to Postgresql that are working fine. Both psql and nc are connecting to postgresql fine both via localhost and 0.0.0.0 host names.
So I have been trying to reproduce your scenario, but instead of using two separate containers, I use docker compose, which i strongly suggest for these kind of activities.
Thank you again for this. I was able to use docker compose to spin up a postgresql database AND a metabase instance that would use that database to create a host of tables within the public schema. The database is visible from psql and dbeaver, and I can see the tables created when Metabase was spinning up.
However, I am still not able to connect to that database from within Metabase, still getting the same connection errors I described above.
I'm not sure why the docker compose workflow would allow the two instances to see each other, but not in the main Metabase database connection window.
Apologies if I'm not describing the components correctly, but I think I've done everything correct in order to set this up as you have described. Any more thoughts are appreciated!
Anyway, if you try to connect to mydatabase from within metabase, it works using the following fields, as declared in the docker-compose file (password is mysecretpassword):
Here is the YAML file I used to spin it all up, as per your example (I used postgis/postgis which is just postgresql with the postgis extension installed and enabled, as well as a few other geospatial extensions)
The IP address that Metabase needs is under "IPAddress", which in this case is 172.17.0.3
Once I used that for the 'host' in the Metabase database connection dialog, everything worked just fine!
Oddly enough I could not find any reference to this anywhere, so perhaps this would be useful to add to the documentation?
(I was going down a rabbit-hole of trying to figure out if this was a pg_hba.conf access issue, but that doesn't seem to be easily addressed (or necessary) with docker instances of postgresql)
THANK YOU VERY MUCH for helping with ALL OF THIS as I learned a lot about Docker Compose figuring it out!!!
Would you happen to have a better explanation than my description of the solution I provided? Just for anyone else who is perhaps trying to figure this out... Thanks!
I think you gave a solid explanation how you solved that issue. Eventually when people will look for a similar issue, will end up here, finding your answer!
Found this while trying to connect a postgres docker container as a database and neither localhost or the IP address worked. What worked for me was using host.docker.internal as the host.