Communication between backend containers

In some cases it can be useful to split up a URCap into multiple backend containers. This presents the challenge of how to communicate between the two containers when the IP address is dynamic for the containers at container-start up.

In this case it is possible to use the servicegateway alias to allow for an executable to communicate out of its container to some client that are available on the host network i.e. a sibling container.

An example where a URCapX has been made with the following manifest file.

vendorId: UniversalRobots
urcapId: InterBeCom
containers:
  - id: containerName_1
    image: example_image_1:latest
    ingress:
      - id: rest-api,
        containerPort: 2345
        protocol: http
        proxyUrl: /
  - id: containerName_2
    image: example_image_2:latest

This URCap contains two backend containers, where containerName_1 includes a webserver that is hosting internally on localhost:2345/. For more details see Creating a container backend Contribution.

Inside the implement of the containerName2 it is then possible to make specific requests against http://servicegateway/UniversalRobots/InterBeCom/containerName_1/rest-api/ to hit the webserver of containerName_1.

In this example the same URCap is providing both backend containers, but that is not a necessity for this to work. It is possible to make requests against backend containers from separate URCaps as long as the URI follows http://servicegateway/vendorID/urcapID/containerId/ingressId/.