dockerdebuggingwebspherewebsphere-8

How to enable DEBUG mode in Docker for IBM Websphere Traditional Image by Default


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")

Solution

  • Solution extracting properties-file based configuration from admin console updates

    1. Start initial container

    docker run --name mywas -p 9043:9043 -p 9443:9443 ibmcom/websphere-traditional:8.5.5.22

    1. Grab generated wsadmin password

    docker exec -it mywas bash -c "cat /tmp/PASSWORD";

    1. Open admin console (point browser to: https://localhost:9043/ibm/console/ )

    2. Click to enable server for debug (use Debugging Service or Application servers > server1 > Process definition > Java Virtual Machine

    3. Click Apply to save

    4. 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)

    1. (Within wsadmin session), extract properties

    print AdminTask.extractConfigProperties('-configData Node=DefaultNode01 -propertiesFileName /home/was/jvm.props -filterMechanism SELECTED_SUBTYPES -selectedSubTypes JavaVirtualMachine')

    1. Back in host, copy properties out of container

    docker cp mywas:/home/was/jvm.props jvm.props

    1. Copy jvm.props properties file to location of your Dockerfile and add COPY to /work/config
    FROM ibmcom/websphere-traditional:8.5.5.22
    COPY --chown=was:root jvm.props /work/config/
    RUN /work/configure.sh
    
    1. 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.

    COMMENTS

    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.