Search code examples
dockerclickhouseapache-superset

Adding local data_base to apache-superset using docker-composer


I can't connect a local database to docker-compose running a Superset container.

I'm using Superset to show information of a database that is stored locally. While Superset is running as a container ran by docker-compose. Superset can't access the database duo to the container network not being able to access the same IP address and port of localhost.


Solution

  • You can connect to your local database by using the docker daemon's network bridge docker0.

    • use docker0's address (172.17.0.1) instead of localhost
    ~ ip addr show docker0
    9: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
        link/ether 1a:2b:3c:4d:5e:6f brd ff:ff:ff:ff:ff:ff
        inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
           valid_lft forever preferred_lft forever
    

    Apache Superset's documentation also mentions this here. More information on your underlying question: From inside of a Docker container, how do I connect to the localhost of the machine?