I've setup an app where a nodejs backend has to communicate with a rasa chatbot backend through a react frontend. All services are running through the same docker-compose. Being a docker beginner there are some things I'm not sure about:
communication between host and container is done using the container's ip
- browser opening the local react server running on
localhost:3000or172.22.0.1:3000 - browser sending a request to the express backend on
localhost:4000172.22.0.2:4000
however communication between two docker containers is done is the container's name:
- rasa server conmmunicating with the rasa custom action server through
http://action_server:5055/webhooks - rasa custom action server communicating with the express backend through
http://backend_name:4000/users/
my problem is that when I need to contact the rasa backend from my react front end I need to put the rasa docker container's ip which (sometimes) changes upon docker-compose reinitialization. To workaround this I do a docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' app_rasa_1 to get the ip and manually change it into the react frontend.
is there a way to avoid changing the ip alltogether and using the container name (or an alias/link) or what would be a way to automate the change of the container's ip in the react frontend (are environment variables updated via a script an option?)