Comment on page

Access local database or API

By default, docker-hosted instances uses a bridge network, which does not support access to service on the host via or localhost. Here we take PostgreSQL as an example and show you how to access local API or database in different operating systems (OS) for docker-hosted Openblocks.


Assume that a Postgres service is ready on your local host with port 5432. Confirm that access to the Postgres service functions well.

How to access local database or API

Windows & Mac
  1. 1.
    Enter ifconfig docker0 in the terminal, and verify the IP configuration of Docker's virtual bridge (VB).
    Having set up Docker, the OS would automatically create docker0 with the IP address (by default), through which the Docker service communicates with the host.
  2. 2.
    Enter the same IP address into Openblocks to configure the Postgres data source ( in this example, but use the actual IP address displayed on your terminal in real case).
On some OS (such as Ubuntu), port access might be blocked by the firewall. To solve that, configure in the following steps:
  1. 1.
    Stop the firewall from blocking access from docker0 by typing in the terminal: iptables -A INPUT -p tcp -i docker0 --dport YOUR_DB_PORT -j ACCEPT Note: In this caseHere we use Postgres port 5432 for YOUR_DB_PORT, and you should replace it with your own.
  2. 2.
    Save the firewall configuration by typing in the terminal: iptables-save > /etc/iptables.up.rules
On Windows and masOS, Docker does not create the virtual bridge docker0. Then the following DNS is helpful to resolve the host IP:
In Openblocks, configure the Postgres data source as the following figure shows: