org.openqa.selenium.WebDriverException: Session [null] not available and is not among the last 1000 terminated sessions using SeleniumGrid in Docker

I am running selenium grid and has 2 nodes connected to it. But when I try to run a test script (.java) it gives the error:

Exception in thread "Thread-23" org.openqa.selenium.WebDriverException: Session [null] not available and is not among the last 1000 terminated sessions.
Active sessions are[ext. key 3e5f8fb2ae3b0c5cddc8817f80eb8fe1]
Command duration or timeout: 92 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'

In the VNC client the chrome browser opens up but the url is not getting loaded and the error is thrown.

Note: The script is run from another docker container using maven.

When I run the script as a java application, it works fine, but in docker, I’m getting the error.**

Source: StackOverflow