I have multiple micro-services running inside containers, and I need to pass few JAVA_OPTS environment variables to one of these containers for testing. Is there easy way to set these variables inside the container, and then restart the java process? Or is the only way to modify the deployment of the services?
If your image is done right, the container should die with the java process.
This leaves us to: you can pass the JAVA_OPTS while creating the container using environment variables. If the Dockerfile already declared
ENV JAVA_OPTS, your passed in environment variables will replace its value…
Thank you. Problem is that, as I am trying the activate the JMX on JVM, and I need to test the configuration with one microservice instead of all. And microservices/containers are currently build with the same gradle file, so the JMX would be on every microservice (this would also drop some of them from use).
Also as I’m testing / searching for the right configuration, It might take few times, so it would be more faster and cleaner to do testing with configuration directly to container with one microservice.
But if not possible to add varialbes “on fly” then perhaps I need to start looking for how customise OPTS only for one microservice. Even as it would be not necessary, after I find the configuration I will deploy and use in on every microservice.