we have an application WAR that runs on traditional websphere. For local testing we create a docker image for our app based on the "ibmcom/websphere-traditional:8.5.5.22" docker image.
This works fine as such, but when I want to debug my app within the docker container via remote debugging I have to enable DEBUG mode for the server manually through the admin console first. And then I need to restart the server/container.
I am wondering is there a different way of doing this? Like applying some props to the new image that will start my application server in DEBUG mode by default?
Thanks
UPDATE
I've been playing with wsadmin scripts. When making the change through web adminconsole and scripting the change out as suggested by lwestby I came up with the following python func which I included in our install.py.
But its not doing the job. Where would I actually see the logger or stdout output from such python scripts?
Thanks
def enableDebug():
try:
server1 = AdminConfig.getid('/Cell:DefaultCell01/Node:DefaultNode01/Server:server1/')
AdminConfig.create('DebugService', server1, '[[BSFDebugPort "4444"] [enable "true"] [jvmDebugPort "7777"] [jvmDebugArgs "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7777"] [debugClassFilters ""] [BSFLoggingLevel "0"]]')
jvm = AdminConfig.list('JavaVirtualMachine', server1)
AdminConfig.modify(jvm[0], '[[debugMode "true"]]')
except:
logger("EXCEPTION ENABLING DEBUG FOR server1")
docker run --name mywas -p 9043:9043 -p 9443:9443 ibmcom/websphere-traditional:8.5.5.22
docker exec -it mywas bash -c "cat /tmp/PASSWORD";
Open admin console (point browser to: https://localhost:9043/ibm/console/ )
Click to enable server for debug (use Debugging Service or Application servers > server1 > Process definition > Java Virtual Machine
Click Apply to save
Launch wsadmin
docker exec -it mywas bash -c "/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -lang jython -user wsadmin -password <password>"
(Accept self-signed cert. if prompted)
print AdminTask.extractConfigProperties('-configData Node=DefaultNode01 -propertiesFileName /home/was/jvm.props -filterMechanism SELECTED_SUBTYPES -selectedSubTypes JavaVirtualMachine')
docker cp mywas:/home/was/jvm.props jvm.props
FROM ibmcom/websphere-traditional:8.5.5.22
COPY --chown=was:root jvm.props /work/config/
RUN /work/configure.sh
docker build
(notice the build will take a bit of time, as your props are "applied" via wsadmin via the websphere docker tooling utils)Your new image will be enabled for debug.
This is clearly more work than adding a single wsadmin script (as in @lwestby's answer). One nice aspect of the properties file approach is you only have to learn a single wsadmin command AdminTask.extractConfigProperties, instead of learning different commands for each admin/config object type. Learning the different commands isn't as much of a challenge as it might seem given the assistance mentioned in lwestby's answer but there might be times when it's easier to just work with the properties more directly, possibly filtering them, like in the example in this answer.