Reputation: 1545
I have a Dockerfile
similar to this one:
FROM tomcat:7-jre8-alpine
...
ENTRYPOINT ["sh", "docker-entrypoint.sh"]
I would like to be able to use it in production after doing all testing and development. During development I'd like to use JRebel and activate debugging, preferably without making changes to the Dockerfile or needing an additional one. To use JRebel unfortunately the jrebel.jar
needs to be part of the container/image and JAVA_OPTS
need to be enhanced with:
"-javaagent:/jrebel.jar -Drebel.remoting_plugin=true"
Also the tomcat debuggin has to be enabled with:
"-agentlib:jdwp=transport=dt_socket, address=1043, server=y, suspend=n"
Is it possible to have one Dockerfile
and then via run options or something like that enable the development options I need? What would be a feasible option to have a "productive" docker image that can be used to run a container during development?
Upvotes: 1
Views: 914
Reputation: 17301
The typical way is to specify a different command when you start your container. You can overwrite both ENTRYPOINT and CMD.
docker run -d --entrypoint "[]" myimage sh -c "./init.sh && ./some-other-script.sh && echo 'about to start' && ./docker-entrypoint.sh"
If the last instruction in your command is the main application, remember to use exec
so that it will run as PID 1 and receive the proper SIGKILL and SIGTERM. Eg:
docker run -d nginx sh -c "./inject-my-vars.sh && exec nginx -g 'daemon off;'"
Upvotes: 1
Reputation: 1328712
then via run options or something like that enable the development options I need?
As a possible "run option", you could use an environment variable that you define on the docker run
command (or the docker-compose
'environment
' directive).
docker run -e "env=dev" ...
Then you can have your image use a script which adapts the JAVA_OPTS
or tomcat options, depending on $ENV
.
If $ENV
is not defined, or defined and equals to anything but "dev
", then you don't activate the debug options.
Upvotes: 1