0

I have one apps which contains 10 java main class . Each main class has own responsibility.

I want to call each class in docker using class name parameter.

My Docker Image like below.
FROM azul/zulu-openjdk-alpine:11
ADD xyzproject/target/abc.jar abc.jar
CMD ["java", "-cp", "abc.jar" ,"Class1"]

I want to run multiple class using docker run argument parameter Please suggest and help me to resolved

ak2020
  • 85
  • 2
  • 10
  • Does this answer your question? [Can I run multiple programs in a Docker container?](https://stackoverflow.com/questions/19948149/can-i-run-multiple-programs-in-a-docker-container) – kthompso Apr 14 '21 at 13:25

1 Answers1

2

You can supply an alternate CMD when you launch the container:

docker run ... xyzproject/abc \
  java -cp abc.jar Class2

The Compose command: and Kubernetes Pod args: similarly replace the CMD part.

If the java command is too involved, you can write a wrapper script to launch each embedded application:

#!/bin/sh
# run_class3.sh
exec java -cp abc.jar Class3 "$@"
docker run ... xyzproject/abc \
  ./run_class3.sh
David Maze
  • 130,717
  • 29
  • 175
  • 215