Running Actyx/Pond V3 in Docker: How to set docker.host.interal instead of localhost

Hi Guys,

since Actyx v2 was released apps are no longer deployed directly onto the node.
Now the developer has to manage the correct deployment of the docker-container.
We all know that Docker-Containers have their own network-provider, so when the actyx/pond npmjs-package is trying to connect to the node i.e. "http://localhost:4454/api/v2/node/id" it will no longer return a valid answer.

I’m looking for the correct env-var to fix that.
Prior to Actyx v2 adding the "-e AX_STORE_URI="..."" flag to the docker run command would have been enough, reference.
But since v2 there is the Auth-API etc.
So with which flag do I tell actyx/pond to use "host.docker.internal" instead of "localhost"?

Hi @LennartBusekrus , the environment variable name is still the same, but the rest slightly changed. In your case, the correct option would be -e AX_STORE_URI="host.docker.internal:4454/api/v2". All Actyx APIs (Events, Auth, Node) are now using port 4454.

We also plan to update the advanced tutorial in the coming days so that the example you linked works properly with v2 :slight_smile:

1 Like

Thank you. I assumed there was an env-var for every API. But this is much simpler. :+1:

Hi @max,

the solution you proposed really worked well on Windows. Let’s say I want to do the same on Linux. I would:

  1. add a new host and specify the AX_STORE_URI, since host.docker.internal does not work on Linux
--add-host=host.docker.internal:host-gateway -e AX_STORE_URI="host.docker.internal:4454/api/v2"
  1. Change the iptables on my Linux machine to accept all connections coming from docker containers
iptables -A INPUT -i docker0 -j ACCEPT

The ‘AX_STORE_URI’ var now points to the docker0 interface e.g. ‘172.17.0.1’, it is used to connect to for example host services like Actyx. The local host now accepts all incoming connections from docker0. So theoretically the connection from inside my docker-container ‘172.17.0.1:4454/api/v2’ should go through to ‘localhost:4454/api/v2’.

The problem is that it only works theoretically. In practice I get the following ERR when connecting ‘localhost:4454/api/v2’ via docker0 [172.17.0.1:4454/api/v2].

ECONNREFUSED 172.17.0.1:4454

This could have the following reasons I can make up.

  1. the actyx-bin does not listen to ‘0.0.0.0:4454’

  2. the actyx-bin does not listen to ‘docker0:4454’ => ‘172.17.0.1:4454’

If you want to recreate this try the following:

Will connect you to SSH

telnet 172.17.0.1 22

Will refuse connection

telnet 172.17.0.1 4454

Hi @LennartBusekrus,

I think the simplest solution would be, to run your docker container with --network=host this way you get rid of all the network routing you are struggling with.

I think this section here would help you with that.

1 Like

Thanks, completely forgot that was an option on Linux. :+1: