Talk to service on same node


I’m wondering how I can communicate between two tasks on the same node.

I tried placing them into one group, but my tasks must run independently. If one task fails within a group, Nomad stops the entire group.

I also attempted to use Consul DNS, but I require direct communication with a specific task on the same node. And Consul has no filtering for that.

How can I achieve this?
Thank you.

@eugenyshcheglov probably the simplest solution would be to have the tasks use host networking mode and give them each a static port assignment. Then your task would just connect using <localhost>:<port>.

You could also skip the network layer and have the tasks communicate over a shared Unix Domain Socket that gets volume mounted into each group.

A third option would be to make use of Nomad or Consul service discovery, and use the template block to render services, filtering out ones that do not match the local host IP.