'Dockerized React webapp cannot communicate to local Dockerised Spring Boot REST API

To start, i am very new to Docker, so troubleshooting has proven very tricky, and as a last ditch effort i'm hoping someone more knowledgeable than myself can help.

Basically my project has 3 Docker containers running on a Debian VM on Google Cloud platform.

  1. MySQL 5.7
  2. React Webapp
  3. Spring Boot REST API

All three are on the same local bridge network called pms-net. The containers have their ports mapped like so: enter image description here

Compose:

enter image description here

Using the external ip provided through the Google Cloud Platform dashboard you can connect to the site without issue, but whenever you perform an action that would make an API call, it just times out. enter image description here

For the IP in the request; ive tried the external ip, the local network ip, localhost, the container id, the subnet ip, subnet gateway, and nothing works. All of them timeout. (The reason for some not working is more evident than others. Just needed to try everything)

My issue arises from the fact that i don't know if my containers are setup incorrectly (or the local network they are on) or if i am just making the API call to the wrong address. I am inclined to believe it is the latter though.

From the VM i can make a cURL via the subnet Gateway (172.18.0.1):

curl -X POST -H "Content-Type: application/json" \
    -d '{"id": "[email protected]", "password": "password"}' \
    http://172.18.0.1:8080/api/login;

And it works just fine. I can do the same with localhost and the subnet IP 172.18.0.3

I'm sure I'm missing something obvious. But the rubber duck is no longer talking back, and I'm at a loss. Any and all help appreciated.



Solution 1:[1]

If you can't cURL your VM from outside, how about firewall rules for your API. Is it open? Everything looks fine on screen shots.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 oyaro-tech