简体   繁体   中英

Accessing backend services on Docker Container from React front end requires IP, rather than localhost

We have a multi-containerized application(docker-compose) running on our Docker Desktop. There is one Camunda BPM backend service running on a container which we are trying to access from our front end application based on React running on other container. The issue we are facing is that, when are trying to access Camunda BPM service through the exposed port using "localhost" its not working. But things work when we use local IP on the host machine. What it makes different between localhost and local IP while accessing a service on back end from a front end REACT application?

When two services (containers) are running within docker-compose they are using a dedicated network. Thus, the services can communicate by their names and not localhost .

If you call your camunda's service camunda and it is listening on port 8080 - the react service can access it via http://camunda:8080

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM