API calls across Docker containers
<p>I am trying to use the provided API from one docker container (let's say <code>container_A</code>) to access another container (<code>container_B</code>). These two containers are in the same Docker network. Before adding Docker I would of course make API calls to <code>http://localhost:{app_port}/{endpoint}</code> and now that I have Dockerized the application, each service is in a Running in a Docker container, I know from reading other questions and websites that you have to use the alias of the container if they are on the same network, or the service name if using <code>docker compose</code> For example <code>http://container_A:8000/books</code>. I've done this but it doesn't work. I configured CORS in all services and also tried accessing the endpoint from within the <em>REST Client</em> (which is a Postman-like VSCode extension) to see if that worked, and it did. I also did port mapping/port exposure. </p>
<p>Just to provide a little more background, I want to use the API from one Docker container containing a Node.js application to access another container containing a React application. </p>
<p>Any ideas on why this doesn't work? </p>