Connect "Apache Superset©" to MySql on Host-machine from Docker-container

👉 Starting out with Apache Superset? ♾
⚠️ These are the things I came accross, scratching my head for a while

Off we go:

  • building Superset using the github Superset repository is easy, bút might not be the best approach if you're not actively going to develop new features for the platform itself
     
  • after checking out the demo with provided datasets, graphs and dashboards, you'd probably want to start using your own dataset, right?
     
    • so I wanted to connect Superset, which was running inside a docker container, directly to my application database (MariaDB) running on my host-machine. 
    • when trying to setup a new datasource connection in Superset a database URI should be provided:
      • ❌  mysql://<user>:<password>@localhost:3306/<database_name>: did not work, docker could not connect using the unix_socket 
      • ❌  mysql://<user>:<password>@127.0.0.1:3306/<database_name>: did not work, ofcourse the database is not provided on that specific container
      • ❌  mysql://<user>:<password>@mysql_host:3306/<database_name>: might have worked using "extra_hosts" or a specific docker network in your docker-compose.yml but this already seemed too much work to me and never felt like this was the out-of-the-box feature to connect to a service running on the host-machine..
      • ✅  luckily after some time, this was the answer I was looking for: "Long live the king... Stackoverflow, long live Stackoverflow!!"
        • try this URI and it should work like a charm: mysql://<user>:<password>@host.docker.internal:3306/<database_name> 🚀

 

Hope this might help!

G.

 



Read Previous
Howto develop a php composer package for Laravel