Running Javascript Selenium Tests within a Node Container for Github Actions

I am trying to create a CI/CD automation flow where when code is pushed to github, my selenium based tests automatically run using Docker. I am having trouble getting each piece of my application to communicate to effectively run the tests as I have multiple containers running simultaiously.

Container 1: React application (localhost:8000)
Container 2: Rails backend (localhost:3000)
Container 3: postgres db (localhost:5432)
Container 4: webdriverio/selenium-standalone image (localhost:4444)

Since the React container will have the JS test I believe I need to include a “usingServer” flag to my builder within the test to reference the selenium-standalone image.

driver = await new webdriver.Builder().setChromeOptions(chromeOptions).forBrowser('chrome').usingServer("http://localhost:4444").build()

before trying to reach the react at localhost:8000

driver.get("localhost:8000")

When I try running the tests locally within the docker containers I am getting an ERRCONNREFUSED for 4444 and 3000.

docker exec react npm run test

My main question is how can I create the connection between these containers such that the browser running in port 4444 can reach the react app in port 8000 and backend at port 3000. The ultimate goal is to then get this automation to run on a Github action.

I have exposed the port within the Docker compose file, tried running the tests within Github actions outside of a container, added additional chrome setting such as headless mode.