Need to help to pass the main class or jar file with JVM arguments into the docker-compose

242 Views Asked by At

I am able to run my stand-alone Flink app from the command line like:

java -Xms15g -Xmx28g -jar stream-processing-1.3.jar

I need to run the application within the Docker container. From an example (Docker Compose JVM parameters), I understood I might pass those arguments inside the Docker file.

Questions:

  1. I wonder if I could pass the above arguments inside the docker-compose.yml rather than the Docker file?

  2. If so, should the command contain the main class file or the jar file?

  3. How to pass those JVM arguments (XMX, XMS)?

This is the sample of my docker-compose-yml:

version: "2.2"
services:
  jobmanager:
    build: .
    image: varimat-stream-processing:1.2
    hostname: jobmanager
    container_name: jobmanager
    ports:
      - "8081:8080"
    command: standalone-job --job-classname com.StreamCommand
1

There are 1 best solutions below

0
newbie5050 On

I ended up passing JVM arguments inside the Dockerfile and it worked:

FROM maven:3.8.1-openjdk-11 AS build
RUN mkdir -p /app/src
COPY src /app/src

COPY pom.xml /app

RUN mvn -f /app/pom.xml clean package

COPY --from=build /app/target/dependency-jars /opt/flink/lib/dependency-jars

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "-Xms14g", "-Xmx28g" ,"/opt/flink/lib/stream-processing-1.3.jar"]