Torizon: Making REST calls from another container

Hi team,

I have a RESTful API in one of my containers (A) and a web service / frontend (B) in another one. Both are using Flask. Communication between both seems to be working because I have a wait-for-it command in my Docker-compose that looks for the hostname:port of container A before launching B.

Container A contains the logic to GPIOs, PWM and such, and works well when I access it from my PC directly through the module’s IP and exported port. Something like: http://<IP>:5001/gpio/0/22/OUT/0

Now I’m trying to create a button in container B that will make this call. For that, I added a simple HTML to make this call with the hostname like http://<hostname>:5001/gpio/0/22/OUT/0 and it gives me an 404. Checking the logs, the calls are not reaching container B.

The HTML used looks like this: <a href="http://gpio-python-rest:5001/gpio/0/22/OUT/0" class="btn btn-info" role="button">GPIO 1 off</a>

What am I missing? Should I be adding extra logic in container B for making this? Probably is just a stupid HTML mistake but it’s been ages since I last touched it :stuck_out_tongue: Thanks! Alvaro.

Hi @alvaro.tx,

Unfortunately I’m not to much better a person to ask in terms of HTML. But I have some ideas on what you could do.

So currently how are you launching your containers? Are you doing it via “docker run” and publishing/exposing the ports that way? Because I believe setting up a docker-compose file for both containers then launching them this way would be easier.

When containers are launched via docker-compose it actually sets up a container network stack where all containers defined in your compose file are a part of. This way by default you know all containers in this network can be reached/discovered by other containers.

Best Regards,

Hi @jeremias.tx, thanks.

As mentioned, I’m launching this with docker-compose. And as also mentioned, it seems the container is reachable since the “wait-for-it” script can find it. The problem is when making the call from my HTML.

Hi @alvaro.tx

Is the issue solved now?