"insufficient memory for the Java Runtime Environment to continue" error indicated when attempting to run docker Image

I am quite new to Docker and selenium-related technologies. When attempting to run a docker image created related to the Java 17 application that uses Maven build and Selenium.

The below error is indicated. Could someone suggest How can this issue be resolved? Any suggested Improvements to the Docker file that might help avoid this issue occurring?

Error Thrown

**Docker run  command used** - sudo docker run selenium_app
[**0.005s][warning][os,thread] Failed to start thread "GC Thread#0" - pthread_create failed (EPERM) for attributes: stacksize: 1024k, guardsize: 4k, detached.**
**#**
**# There is insufficient memory for the Java Runtime Environment to continue.**
**# Cannot create worker GC thread. Out-of-system resources.**
**# An error report file with more information is saved as:**
**# /app/hs_err_pid1.log**

Docker Build command used - sudo docker build -t selenium_app .

Related Docker file

# Use the official OpenJDK 17 image as a base image
#FROM maven:3.6.3-openjdk-17 AS build
FROM maven:3.9.6-eclipse-temurin-17-alpine AS builder

# Set the working directory inside the container
WORKDIR /app
RUN chmod -R 777 /app

# Install tools.
RUN apt update -y & apt install -y wget unzip
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y tzdata

# Install Chrome.
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get update
RUN apt-get install -y google-chrome-stable

# Install ChromeDriver.
RUN wget -N https://chromedriver.storage.googleapis.com/105.0.5195.19/chromedriver_linux64.zip -P ~/
RUN unzip ~/chromedriver_linux64.zip -d ~/
RUN rm ~/chromedriver_linux64.zip
RUN mv -f ~/chromedriver /usr/local/bin/chromedriver
RUN chmod +x /usr/local/bin/chromedriver

# Copy the entire project (assuming Dockerfile is in the project root)
COPY . .

# Build the application using Maven
RUN mvn package -DskipTests

# Use the official OpenJDK 17 image as the final image
#FROM openjdk:17-alpine
FROM eclipse-temurin:17.0.6_10-jdk@sha256:13817c2faa739c0351f97efabed0582a26e9e6745a6fb9c47d17f4365e56327d

# Set the working directory inside the container
WORKDIR /app

# Copy the JAR file from the build stage to the final stage
#COPY --from=build /app/target/*.jar app.jar

# Copy the JAR file and other necessary files to the container
#COPY out/artifacts/report_automation_jar/report-automation.jar /app/report-automation.jar
COPY report-automation.jar /app/report-automation.jar
COPY src/main/resources/META-INF/MANIFEST.MF /app/META-INF/MANIFEST.MF
COPY src /app/src

COPY src/main/resources/META-INF/MANIFEST.MF /app/META-INF/MANIFEST.MF
COPY src/main/resources/config.properties /app/config.properties
COPY pom.xml /app/pom.xml
COPY testng.xml /app/testng.xml
COPY application.properties /app/application.properties
COPY Configuration.xlsm /app/Configuration.xlsm
COPY apache-maven-3.9.6/ /app/apache-maven-3.9.6/
COPY Downloads /app/Downloads
COPY Logs /app/Logs
COPY report /app/report
COPY Reports /app/Reports

# Expose the port (if your application listens on a specific port)
# EXPOSE 8080

# Set the entry point for the container (replace with your main class)
ENTRYPOINT ["java", "-jar", "report-automation.jar"]

Sounds like the node running the build does not have enough free RAM.

Local machine memory is available (32GB) and hardly utilized. How can I handle this scenario in relation to the node running the docker build?

Do you run this with Docker Desktop? Because that uses VMs with potentially lower available RAM.