It is definitely possible for applications in multiple jobs to talk to each other. This is an example job, that talks to your WebSocket application using the Nomad Service Discovery option.
Adding to the answer given from @Ranjandas, this is absolutely possible. The service discovery networking page is a good starting point for understanding what is possible and how to get started.
That’s a good example for the Nomad provider, thanks!
Do you have an example on how the same could be done in the same manner with the Consul provider? I’m struggling to understand the Consul template format.
{{- $dns_forward := "192.168.0.1:53" }}{{- /* init with router IP */}}
{{- range service "adguard-dns" }}{{- /* iterates over [0..1] instances of the adguard-dns service */}}
{{- $dns_forward = print .Address ":" .Port }}{{- /* overwrite with AdGuard ip:port if service is present */}}
{{- end}}
forward . {{ $dns_forward }}{{- /* generate forward entry */}}
This is the part which reconfigures my CoreDNS to forward DNS requests to the AdGuard Home service, or the router if the AGH service is not available.
In addition, Consul has quite a few features to link services together:
Consul DNS, which let’s you point your FE-service to <backend_service>.service.consul:<port>
Consul Connect, to transparently link your BE-service to localhost:<port> of the FE-task group.