Wednesday, 6 February 2019

WebSphere Liberty Profile on Docker - An update

In the context of my current project, we were talking about running WebSphere Liberty Profile on Docker, so here's an update: -

Pull Liberty Docker Image

docker pull websphere-liberty

Using default tag: latest
latest: Pulling from library/websphere-liberty
7b722c1070cd: Pull complete 
5fbf74db61f1: Pull complete 
ed41cb72e5c9: Pull complete 
7ea47a67709e: Pull complete 
449210cbff3b: Pull complete 
18c9d73c43bb: Pull complete 
34afdf15398d: Pull complete 
83a69d4d0146: Pull complete 
bb817bf5c90c: Pull complete 
ebb9f104335d: Pull complete 
7714cd589690: Pull complete 
d5191570a227: Pull complete 
79c80066476d: Pull complete 
acf01b72e712: Pull complete 
c9445dae1684: Pull complete 
Digest: sha256:fa2aaccc861c66fa20c8d6f67b8913b10517e6e441d2420d525e591b718c2e77
Status: Downloaded newer image for websphere-liberty:latest

Validate the image

docker images

REPOSITORY                                  TAG                 IMAGE ID            CREATED             SIZE
websphere-liberty                           latest              a83fa38506a5        4 days ago          585MB
hello-world                                 latest              fce289e99eb9        5 weeks ago         1.84kB
registry.ng.bluemix.net/davehay42/davehay   helloworld          fce289e99eb9        5 weeks ago         1.84kB

Start a container

- Note that we're using the -v ( aka --volumes ) switch to make a local WAR file available to the container
- Note that we're also mapping ports using -p and running the container as a daemon ( -d )

docker run -d -p 80:9080 -p 443:9443 -v /tmp/ferret-1.2.war:/config/dropins/ferret-1.2.war websphere-liberty:latest

4823dd0bc7a690a1ae6eafce6a0a8611fdf4cc73f6beadd6436c67c1a4838231

- Note that the container ID is in full; the short version is 4823dd0bc7a6 as will be seen later using docker ps -a

Check the container logs

docker logs 4823dd0bc7a690a1ae6eafce6a0a8611fdf4cc73f6beadd6436c67c1a4838231

Launching defaultServer (WebSphere Application Server 19.0.0.1/wlp-1.0.24.cl190120190124-2339) on IBM J9 VM, version 8.0.5.27 - pxa6480sr5fp27-20190104_01(SR5 FP27) (en_US)
[AUDIT   ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT   ] CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/19.0.0.1/lafiles/en.html
[AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ibm/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[WARNING ] CWWKS3103W: There are no users defined for the BasicRegistry configuration of ID com.ibm.ws.security.registry.basic.config[basic].
[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications.
[AUDIT   ] CWWKS4104A: LTPA keys created in 0.650 seconds. LTPA key file: /opt/ibm/wlp/output/defaultServer/resources/security/ltpa.keys
[AUDIT   ] CWPKI0803A: SSL certificate created in 2.125 seconds. SSL key file: /opt/ibm/wlp/output/defaultServer/resources/security/key.jks
[AUDIT   ] CWWKI0001I: The CORBA name server is now available at corbaloc:iiop:localhost:2809/NameService.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://4823dd0bc7a6:9080/ferret/
[AUDIT   ] CWWKZ0001I: Application ferret-1.2 started in 0.725 seconds.
[AUDIT   ] CWWKF0012I: The server installed the following features: [beanValidation-2.0, servlet-4.0, ssl-1.0, jndi-1.0, jca-1.7, cdi-2.0, jdbc-4.2, jms-2.0, ejbPersistentTimer-3.2, appSecurity-3.0, appSecurity-2.0, j2eeManagement-1.1, wasJmsServer-1.0, javaMail-1.6, jaxrs-2.1, webProfile-8.0, jpa-2.2, jcaInboundSecurity-1.0, jsp-2.3, jsonb-1.0, ejbLite-3.2, managedBeans-1.0, jsf-2.3, ejbHome-3.2, jaxws-2.2, jsonp-1.1, jaxrsClient-2.1, el-3.0, concurrent-1.0, appClientSupport-1.0, ejbRemote-3.2, jaxb-2.2, mdb-3.2, jacc-1.5, javaee-8.0, batch-1.0, ejb-3.2, jpaContainer-2.2, jaspic-1.1, distributedMap-1.0, websocket-1.1, wasJmsSecurity-1.0, wasJmsClient-2.0].
[AUDIT   ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.

Test the Ferret app using cURL

curl http://localhost/ferret/

Test the Ferret app using a real browser



Look at the running Docker container(s)

docker ps -a

CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS                         PORTS                                         NAMES
4823dd0bc7a6        websphere-liberty:latest   "/opt/ibm/helpers/ru…"   22 minutes ago      Up 22 minutes                  0.0.0.0:80->9080/tcp, 0.0.0.0:443->9443/tcp   keen_torvalds
3d8899de8f32        hello-world                "/hello"                 About an hour ago   Exited (0) About an hour ago                                                 happy_colden

Open a shell to the container

docker exec -i -t 4823dd0bc7a6 /bin/bash

default@4823dd0bc7a6:/$ 

Examine the detailed Liberty messages

default@4823dd0bc7a6:/$ cat logs/messages.log 

Check the Liberty version

default@4823dd0bc7a6:/$ /opt/ibm/wlp/bin/server version

WebSphere Application Server 19.0.0.1 (1.0.24.cl190120190124-2339) on IBM J9 VM, version 8.0.5.27 - pxa6480sr5fp27-20190104_01(SR5 FP27) (en_US)

Exit the shell

default@4823dd0bc7a6:/$ exit

Stop the container

docker stop 4823dd0bc7a6

4823dd0bc7a6

Remove the container

docker rm 4823dd0bc7a6

4823dd0bc7a6

Thanks to this: -

Official IBM WebSphere Application Server for Developers Liberty image.

for inspiration.

No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...