For a while now I’ve had a bullet point on a chart that blithely stated that you could add an application on top of our WebSphere Application Server traditional Docker image using wsadmin and, in particular, with the connection type set to NONE
i.e. without the server running. Needless to say, when I actually tried to do this shortly before a customer demo it didn’t work! Thankfully, with moral support from a colleague and the excellent command assistance in the admin console, it turns out that my initial assertion was correct and the failure was just down to my rusty scripting skills. Here’s how…
First, the Dockerfile that builds an image containing our ferret sample application, taking the WAR file from Maven Central.
1 2 3 4 |
FROM websphere-traditional:profile ENV FERRET_VERSION 1.2 RUN wget http://search.maven.org/remotecontent?filepath=net/wasdev/wlp/sample/ferret/$FERRET_VERSION/ferret-$FERRET_VERSION.war -O /tmp/ferret.war RUN /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -conntype NONE -lang jython -c "AdminApp.install('/tmp/ferret.war', '[ -nopreCompileJSPs -distributeApp -nouseMetaDataFromBinary -nodeployejb -appname ferret_war -createMBeansForResources -noreloadEnabled -nodeployws -validateinstall warn -noprocessEmbeddedConfig -filepermission .*\.dll=755#.*\.so=755#.*\.a=755#.*\.sl=755 -noallowDispatchRemoteInclude -noallowServiceRemoteInclude -asyncRequestDispatchType DISABLED -nouseAutoLink -noenableClientModule -clientMode isolated -novalidateSchema -contextroot ferret -MapModulesToServers [[ ferret ferret.war,WEB-INF/web.xml WebSphere:cell=DefaultCell01,node=DefaultNode01,server=server1 ]] -MapWebModToVH [[ ferret ferret.war,WEB-INF/web.xml default_host ]]]' );AdminConfig.save()" |
The following script then builds an image from the Dockerfile in the gist above, runs it, waits for the server to start, and then retrieves the ferret webpage.
1 2 3 4 5 6 |
docker build -t app https://git.io/viNYX docker run --name app -p 9080 -d app docker logs --tail=all -f app 2> /dev/null | while read LINE; do [[ "${LINE}" == *"WSVR0001I"* ]] && pkill -P $$ docker done curl $(docker port app 9080)/ferret/ |