I'm rather new to working with docker, so it's very possible I just have no idea what I am doing. I have a react frontend that connects to a loopback server. When running them locally, I have the package.json file setup to where I just run "npm start" from the base project directory, and both sides of the application run with one on port 3000 and the other at port 3001. This works well locally, and when I try to hit any API from the frontend, I just need to aim towards localhost:3001/.
I wanted to put them together in a container to sort of match how I have it setup locally, but obviously the path I'm using to communicate between them wont work anymore if that's the case since "localhost" will just look at the users localhost as opposed to the instance in the container. Is there way to keep these two running services on a singular container and have communication between them? I only need the port for one of them (the react frontend) to be exposed to users as that's the only part of the application they would be directly interacting with. Is this type of functionality only possible by making each its' own container and then communicating that way? If possible, I'd like to avoid that.
I've tried searching this up, and I'm sure it's out there somewhere, but I don't think I know enough about docker to properly express what I'm searching for. I'd appreciate anyone with some experience helping me out if possible. Thanks!