What is the method to execute a headless browser within a Docker container?

I’m developing a web crawler utilizing a headless browser, and I need assistance in containerizing my application with Docker. I’ve managed to install Chrome in the Docker image, yet I’m encountering an issue when I try to execute my script. The script, StartChrome.js, utilizes the ‘chrome-launcher’ library to launch Chrome in headless mode. However, I receive an error regarding connection refusal on port 9222. Additionally, running it via the command line yields a permission issue related to namespace operations. Can anyone help me resolve these errors?