This guide steps you through the process to build a simple Open Liberty InstantOn app using podman.
In later guides, you can deploy this Open Liberty InstantOn app to OpenShift.
20 minutes reading time. More time to complete.
Audience
The audience of this guide is anyone having an interest to build Open Liberty InstantOn app.
This guide contains the steps to build this app using podman.
You can happily complete this guide with no development experience. It is most suitable for an admin wanting to learn the basics of building an Open Liberty InstantOn app, and more specifically for a developer who wants to convert their Open Liberty app to InstantOn for faster startup.
Pre-requisites
For this exercise you need to:
- Access to a Linux server – you can use WMware running Linux.
- Building an Open Liberty InstantOn app needs access to the criu (Checkpoint/Restore in Userspace) feature found in Linux.
- Podman needs to be installed on the Linux server.
- While not mandatory, it is recommended to download git and github desktop. You can happily complete this guide by ignoring this step.
- Ensure your firewall is opened to icr.io. This guide pulls a ‘thin’ image from icr.io. During the build process, the required Open Liberty features are installed. This minimizes the image size.
- Refer to the pre-requisites for using Open Liberty InstantOn.
Overview
To build my test image I used a RHEL 9.2 installation running under VMWARE Player 16. These can be downloaded and used for free from the following URLs.
Software | URL |
RHEL 9.2 | https://developers.redhat.com/products/rhel/download#publicandprivatecloudreadyrhelimages7522 |
VMware player 16 | https://www.vmware.com/info/workstation-player/evaluation |
VMware Workstation Pro for Personal Use (For Windows) 17.5.2 (1) | Desktop Hypervisor Solutions | VMware |
(1) 30-Aug-2024: VMware player has been discontinued. WMware Workstation Pro can be used for free for personal use. Further details can be found here.
Of course, if you are using Linux rather than Windows, you can proceed without needing to use VMware.
The Open Liberty InstantOn image needs to be built using the root account.
I tend to do as much of the work as possible using a non-root account. Unless otherwise specified, all work should be completed using a non-root account.
Sample app
For this exercise, I wrote a basic servlet to test Open Liberty InstantOn using podman. The goal being to learn about building an Open liberty InstantOn app, rather than developing apps for running in containers.
To complete this guide, you need to download this sample app.
Download the sample project
Download the sample project from github.
You can clone the project using git or github desktop.
Alternatively, you can download the zip file. Unzip to a location of your choice. For the non-developers, or those not experienced with git and github, I have followed this approach.
Unzip the sample
Log into Linux with the non-root user and create the following in your home directory.
mkdir LibertyToOpenShiftInstantOn
cd $HOME/LibertyToOpenShiftInstantOn
FTP LibertyToOpenShiftInstantOn-main.zip to the $HOME/LibertyToOpenShiftInstantOn directory.
Unzip the file.
unzip LibertyToOpenShiftInstantOn-main.zip
Move the files to the following location. This guide requires all files to be found here.
mv LibertyToOpenShiftInstantOn-main/LibertyToOpenShiftInstantOn/* .
The file structure should be the same as the below.
[sean@localhost LibertyToOpenShiftInstantOn]$ ls -l
total 48
-rw-r--r--. 1 sean sean 751 Aug 18 21:34 Containerfile.olp.slim.java17
-rw-r--r--. 1 sean sean 1709 Aug 18 21:34 deploy_incorrectly_placed_in_spec.yaml
-rw-r--r--. 1 sean sean 1530 Aug 18 21:34 deploy_incorrectly_placed_SA_in_spec.yaml
-rw-r--r--. 1 sean sean 1275 Aug 18 21:34 deploy.yaml
drwxr-xr-x. 3 sean sean 91 Aug 18 21:34 LibertyToOpenShiftInstantOn-main
-rw-r--r--. 1 sean sean 20043 Sep 6 22:12 LibertyToOpenShiftInstantOn-main.zip
-rw-r--r--. 1 sean sean 958 Aug 18 21:34 scc-cap-cr-full-details-dont-use-1.yaml
-rw-r--r--. 1 sean sean 1059 Aug 18 21:34 scc-cap-cr-full-details-dont-use-2.yaml
-rw-r--r--. 1 sean sean 541 Aug 18 21:34 scc-cap-cr-minmal.yaml
drwxr-xr-x. 3 sean sean 18 Aug 18 21:34 src
drwxr-xr-x. 2 sean sean 63 Aug 18 21:34 target
Delete any old images
Switch to the root account.
sudo -i
Change to the directory you created. In my case, the HOME directory is /home/sean. Use your HOME directory.
cd /home/sean/LibertyToOpenShiftInstantOn
Cleanup any old images.
podman images
You will see a list of images.
Command output
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/libertytoopenshift 1.0-SNAPSHOT 015675eb1c03 4 months ago 741 MB
localhost/libertytoopenshiftinstanton 1.0-SNAPSHOT 64879db0d28e 4 months ago 798 MB
icr.io/appcafe/open-liberty kernel-slim-java17-openj9-ubi 385d889567ef 5 months ago 688 MB
Delete any old InstantOn image you no longer need.
podman rmi libertytoopenshiftinstanton:1.0-SNAPSHOT
Command output
[root@localhost ~]# podman rmi libertytoopenshiftinstanton:1.0-SNAPSHOT
Untagged: localhost/libertytoopenshiftinstanton:1.0-SNAPSHOT
Deleted: 64879db0d28e743724f7ce5c8ccc9558502a54aa87352196f055920ab23758d1
Deleted: 338bc1e5601e6679e06d7ff0c1ef25613739e1554560b9c42633ade185d6b79c
Deleted: 6998a04fb8f637cd8e16a0483a7d4adb719ecbba1307299bf44bf4f73111433d
Deleted: 46f0db66cae664004948a09d75d2d9bdaa74cc2aa02dbfbb2fd17b9f9082bb20
Deleted: 9e91a3072d7018e79a559894d3743875bd4151f24138fceeef36fa0a7edd3c28
Deleted: 00239816e1a71de0130fbb2a2440bc808c7c101efadb0a9e1cb383c94fc103a1
[root@localhost ~]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/libertytoopenshift 1.0-SNAPSHOT 015675eb1c03 4 months ago 741 MB
icr.io/appcafe/open-liberty kernel-slim-java17-openj9-ubi 385d889567ef 5 months ago 688 MB
Build the Open Liberty InstantOn image
If the image icr.io/appcafe/open-liberty:kernel-slim-java17-openj9-ubi has not already been downloaded, it will be automatically downloaded for you.
Take note of the parameters. These are required to build an Open Liberty InstantOn image.
--cap-add=CHECKPOINT_RESTORE --cap-add=SYS_PTRACE --cap-add=SETPCAP --security-opt seccomp=unconfined
Refer to Building an InstantOn image with Podman for more details.
Issue the following command to build the InstantOn image.
podman build -t liberty-to-openshift-instanton:olp-java17-1.0 --cap-add=CHECKPOINT_RESTORE --cap-add=SYS_PTRACE --cap-add=SETPCAP --security-opt seccomp=unconfined -f Containerfile.olp.slim.java17
Command output
[root@localhost LibertyToOpenShiftInstantOn]# podman build -t liberty-to-openshift-instanton:olp-java17-1.0 --cap-add=CHECKPOINT_RESTORE --cap-add=SYS_PTRACE --cap-add=SETPCAP --security-opt seccomp=unconfined -f Containerfile.olp.slim.java17
STEP 1/9: FROM icr.io/appcafe/open-liberty:kernel-slim-java17-openj9-ubi
STEP 2/9: ARG VERSION=1.0
--> Using cache f4c74d7b98f42412a079fd9660c81ceadedf1cfec726ae57dd6c65cf79b2d5d5
--> f4c74d7b98f
STEP 3/9: ARG REVISION=SNAPSHOT
--> Using cache cf717c4202b51903b9cbbe5c7d980b220c84cf3b328b41033fd4b14afd05ceaf
--> cf717c4202b
STEP 4/9: LABEL org.opencontainers.image.authors="Sean Boyd" org.opencontainers.image.url="local" org.opencontainers.image.version="$VERSION" org.opencontainers.image.revision="$REVISION" name="LibertyToOpenShift" version="$VERSION-$REVISION" summary="Sample Open Liberty InstantOn app for deploying to OpenShift" description="This servlet has been written to help test running an Open Liberty app in OpenShift"
--> 150747e9c88
STEP 5/9: COPY --chown=1001:0 target/server.xml /config/
--> eeb3078ca8f
STEP 6/9: RUN features.sh
+ SNIPPETS_SOURCE=/opt/ol/helpers/build/configuration_snippets
+ SNIPPETS_TARGET=/config/configDropins/overrides
+ SNIPPETS_TARGET_DEFAULTS=/config/configDropins/defaults
+ mkdir -p /config/configDropins/overrides
+ mkdir -p /config/configDropins/defaults
+ '[' -n '' ']'
+ '[' '' == client ']'
+ '[' '' == embedded ']'
+ [[ -n '' ]]
+ '[' '' == true ']'
+ '[' '' == true ']'
+ featureUtility installServerFeatures --acceptLicense defaultServer --noCache
+ find /opt/ol/wlp/lib /opt/ol/wlp/bin '!' -perm -g=rw -print0
+ xargs -0 -r chmod g+rw
--> ab39c9b6e6f
STEP 7/9: COPY --chown=1001:0 target/LibertyToOpenShiftInstantOn.war /config/apps/
--> 66b86522b37
STEP 8/9: RUN configure.sh
--> 8e0a124ce02
STEP 9/9: RUN checkpoint.sh afterAppStart
Performing checkpoint --at=afterAppStart
Launching defaultServer (Open Liberty 24.0.0.2/wlp-1.0.86.cl240220240212-1928) on Eclipse OpenJ9 VM, version 17.0.10+7 (en_US)
[AUDIT ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.
[AUDIT ] CWWKZ0001I: Application LibertyToOpenShiftInstantOn started in 0.668 seconds.
[AUDIT ] CWWKC0451I: A server checkpoint "afterAppStart" was requested. When the checkpoint completes, the server stops.
COMMIT liberty-to-openshift-instanton:olp-java17-1.0
--> fdeb66c9055
Successfully tagged localhost/liberty-to-openshift-instanton:olp-java17-1.0
fdeb66c9055741fdf705ef1a89d3d04671cd694ce402fba5eaf87c45e191f286
Notice the additional step towards the bottom of the build.
STEP 9/9: RUN checkpoint.sh afterAppStart
Performing checkpoint --at=afterAppStart
Launching defaultServer (Open Liberty 24.0.0.2/wlp-1.0.86.cl240220240212-1928) on Eclipse OpenJ9 VM, version 17.0.10+7 (en_US)
[AUDIT ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.
[AUDIT ] CWWKZ0001I: Application LibertyToOpenShiftInstantOn started in 0.668 seconds.
[AUDIT ] CWWKC0451I: A server checkpoint "afterAppStart" was requested. When the checkpoint completes, the server stops.
COMMIT liberty-to-openshift-instanton:olp-java17-1.0
--> fdeb66c9055
Notice the additional “checkpoint” step towards the bottom of the build.
STEP 9/9: RUN checkpoint.sh afterAppStart
Performing checkpoint --at=afterAppStart
Launching defaultServer (Open Liberty 24.0.0.2/wlp-1.0.86.cl240220240212-1928) on Eclipse OpenJ9 VM, version 17.0.10+7 (en_US)
[AUDIT ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.
[AUDIT ] CWWKZ0001I: Application LibertyToOpenShiftInstantOn started in 0.668 seconds.
[AUDIT ] CWWKC0451I: A server checkpoint "afterAppStart" was requested. When the checkpoint completes, the server stops.
COMMIT liberty-to-openshift-instanton:olp-java17-1.0
--> fdeb66c9055
For a full description of InstantOn refer to the Faster startup for containerized applications with Open Liberty InstantOn page. In particular, refer to the beforeAppStart and afterAppStart options.
If you receive the following error, refer to the following URL for the solution.
Error (criu/proc_parse.c:694): Can't open 1023's mapfile link 55a65bfe8000: Operation not permitted
Error (criu/cr-dump.c:1558): Collect mappings (pid: 1023) failed with -1
Error (criu/cr-dump.c:2093): Dumping FAILED.
CWWKE0963E: The server checkpoint request failed because netlink system calls were unsuccessful. If SELinux is enabled in enforcing mode, netlink system calls might be blocked by the SELinux "virt_sandbox_use_netlink" policy setting. Either disable SELinux or enable the netlink system calls with the "setsebool virt_sandbox_use_netlink 1" command.
Error: building at STEP "RUN checkpoint.sh afterAppStart": while running runtime: exit status 74
Now re-issue the build command again.
podman build -t liberty-to-openshift-instanton:olp-java17-1.0 --cap-add=CHECKPOINT_RESTORE --cap-add=SYS_PTRACE --cap-add=SETPCAP --security-opt seccomp=unconfined -f Containerfile.olp.slim.java17
I received the below error when I issued the setsebool command using root but incorrectly tried to build the image using a non-root account. The following URL describes this error in more derails.
Error (criu/proc_parse.c:379): Failed to resolve mapping 558982528000 filename
Error (criu/proc_parse.c:694): Can't open 1023's mapfile link 558982528000: Operation not permitted
Error (criu/cr-dump.c:1558): Collect mappings (pid: 1023) failed with -1
Error (criu/cr-dump.c:2093): Dumping FAILED.
Error: building at STEP "RUN checkpoint.sh afterAppStart": while running runtime: exit status 74
If you are not building the image using the root account, switch to the root account and re-try. Ensure that the “setsebool” command has also been issued after you switched.
Details on additional errors can be found here.
Verify that the image has been created
Use podman to display the images.
Look for the image you just created named localhost/liberty-to-openshift-instanton:olp-java17-1.0.
If you didnโt already download the image icr.io/appcafe/open-liberty:kernel-slim-java17-openj9-ubi youโll notice that it also exists.
podman images
Command output
[root@localhost LibertyToOpenShiftInstantOn]# podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/liberty-to-openshift-instanton olp-java17-1.0 fdeb66c90557 9 minutes ago 800 MB
localhost/libertytoopenshift 1.0-SNAPSHOT 015675eb1c03 4 months ago 741 MB
icr.io/appcafe/open-liberty kernel-slim-java17-openj9-ubi 385d889567ef 5 months ago 688 MB
(Optionally) Test the image
Optionally test the image using podman before you deploy to OpenShift.
Command | Help |
podman run -d –name CONTAINER_NAME –cap-add=CHECKPOINT_RESTORE –cap-add=SETPCAP –security-opt seccomp=unconfined -p PORT:INTERNAL_PORT REPOSITORY:TAG Note: “–” is two-dashes. The display may appear to be a single dash. | Start the podman container where: CONTAINER_NAME is the name you’ll give the running container PORT is the port you’ll use to access the running container INTERNAL_PORT is the internal port used by your Open Liberty image (not accessible from outside the running container) REPOSITORY:TAG is the image you will use Open Liberty InstantOn options The below are required by the InstantOn checkpoint restore. Note that the option “–cap-add=SYS_PTRACE” is not required when running the Open Liberty InstantOn container, it is only required during the build process. –cap-add=CHECKPOINT_RESTORE –cap-add=SETPCAP –security-opt seccomp=unconfined |
Start the podman container with missing parameters
The below command is missing mandatory parameters. Running this test shows you the error you’ll encounter when you forget to add these parameters – like I did more times than you can count. Go figure!
You can skip this section and continue using podman with all the required parameters if you prefer.
โcap-add=CHECKPOINT_RESTORE โcap-add=SETPCAP โsecurity-opt seccomp=unconfined
Issue the below command to start your podman container.
In the below command you’ll see the first port 9080 is the port you’ll access the running container on.
The second port 9080 is the port used internally by the running container – this is what you specified in the server.xml file.
podman run -d --name liberty-to-openshift-instanton -p 9080:9080 liberty-to-openshift-instanton:olp-java17-1.0
Check the status of any running containers.
podman ps
Command output
[root@localhost LibertyToOpenShiftInstantOn]# podman run -d --name liberty-to-openshift-instanton -p 9080:9080 liberty-to-openshift-instanton:olp-java17-1.0
0f8d146c7403082222e82589cc4e10b97aa7a0a1988f0de999091923bd594429
[root@localhost LibertyToOpenShiftInstantOn]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0f8d146c7403 localhost/liberty-to-openshift-instanton:olp-java17-1.0 /opt/ol/wlp/bin/s... 9 seconds ago Up 8 seconds 0.0.0.0:9080->9080/tcp liberty-to-openshift-instanton
Check the logs
To check whether the container is running fine, check the logs.
Command | Help |
podman logs NAME | Display the container logs. NAME matches the NAMES field in the far-right output of the “podman ps” command. |
Issue the command.
podman logs liberty-to-openshift-instanton
If you check the log output you will see the checkpoint failed with โOperation not permittedโ.
If you compare the logs to starting an image without using the Open Liberty InstantOn feature, you’ll notice the startup time is somewhat degraded. This highlights the importance of ensuring the Open Liberty InstantOn feature doesn’t encounter any errors during the criu checkpoint restore process.
[root@localhost LibertyToOpenShiftInstantOn]# podman logs liberty-to-openshift-instanton
/opt/ol/wlp/bin/server: line 1351: /opt/criu/criu: Operation not permitted
CWWKE0961I: Restoring the checkpoint server process failed. Check the /logs/checkpoint/restore.log log to determine why the checkpoint process was not restored. Launching the server without using the checkpoint image.
Launching defaultServer (Open Liberty 24.0.0.2/wlp-1.0.86.cl240220240212-1928) on Eclipse OpenJ9 VM, version 17.0.10+7 (en_US)
[AUDIT ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.
[AUDIT ] CWWKT0016I: Web application available (default_host): http://0f8d146c7403:9080/
[AUDIT ] CWWKZ0001I: Application LibertyToOpenShiftInstantOn started in 0.754 seconds.
[AUDIT ] CWWKF0012I: The server installed the following features: [el-3.0, jsp-2.3, localConnector-1.0, servlet-4.0].
[AUDIT ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 4.501 seconds.
Connect to the running container
Connect to the running pod and double check the build process, specifically the checkpoint.
Command | Help |
podman exec -ti NAMES /bin/bash | Connect to the running container using the bash shell NAMES is the field at the very righthand side of the “podman ps” command. |
podman exec -ti liberty-to-openshift-instanton /bin/bash
Switch to the logs directory and display the log contents.
cd logs/checkpoint
cat checkpoint.log
The output of the commands should be similar to the following output.
bash-4.4$ cd logs
bash-4.4$ ls -l
total 16
drwxrwx---. 2 default root 46 Aug 13 18:10 checkpoint
-rw-rw----. 1 default root 757 Aug 13 18:10 checkpoint-console.log
-rw-r-----. 1 default root 0 Aug 13 18:22 console.log
-rw-rw----. 1 default root 3233 Aug 13 18:10 messages_24.08.13_18.22.05.0.log
-rw-r-----. 1 default root 4637 Aug 13 18:22 messages.log
bash-4.4$ cd checkpoint
bash-4.4$ ls -l
total 8
-rw-rw----. 1 default root 1489 Aug 13 18:10 checkpoint.log
-rw-rw----. 1 default root 53 Aug 13 18:10 stats-dump
bash-4.4$ cat checkpoint.log
Warn (criu/kerndat.c:1103): $XDG_RUNTIME_DIR not set. Cannot find location for kerndat file
Warn (criu/kerndat.c:1103): $XDG_RUNTIME_DIR not set. Cannot find location for kerndat file
Warn (compel/src/lib/infect.c:133): Unable to interrupt task: 1088 (Operation not permitted)
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1044 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1054 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1057 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1058 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1062 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1063 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1064 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1065 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1067 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1069 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1070 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1071 with interrupted system call
Warn (compel/arch/x86/src/lib/infect.c:356): Will restore 1072 with interrupted system call
You will see the error โUnable to interrupt task: 1088 (Operation not permitted)โ. This was caused as the required parameters were not set when running podman.
Exit from the container.
exit
Stop the running pod.
podman ps
podman stop liberty-to-openshift-instanton
Check the status of any running pods.
podman ps
Command output
[root@localhost LibertyToOpenShiftInstantOn]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0f8d146c7403 localhost/liberty-to-openshift-instanton:olp-java17-1.0 /opt/ol/wlp/bin/s... 32 minutes ago Up 32 minutes 0.0.0.0:9080->9080/tcp liberty-to-openshift-instanton
[root@localhost LibertyToOpenShiftInstantOn]# podman stop liberty-to-openshift-instanton
0f8d146c7403
[root@localhost LibertyToOpenShiftInstantOn]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Start the podman container with the mandatory parameters
Run the command with the required parameters.
podman run -d --name liberty-to-openshift-instanton --cap-add=CHECKPOINT_RESTORE --cap-add=SETPCAP --security-opt seccomp=unconfined -p 9080:9080 liberty-to-openshift-instanton:olp-java17-1.0
Check the status.
podman ps
If you get at error that the container is already in use, remove it. Note that you use โpodman rmโ and not โpodman rmiโ.
Issue the following command to list all running or stopped containers. Note the additional option “-a”. This also lists any stopped containers.
podman ps -a
Now remove the stopped container. Be sure to change the container id below with the one from your “podman ps -a” command.
podman rm f1d25285c018
Try again.
podman run -d --name liberty-to-openshift-instanton --cap-add=CHECKPOINT_RESTORE --cap-add=SETPCAP --security-opt seccomp=unconfined -p 9080:9080 liberty-to-openshift-instanton:olp-java17-1.0
podman ps
Command output
[root@localhost LibertyToOpenShiftInstantOn]# podman run -d --name liberty-to-openshift-instanton --cap-add=CHECKPOINT_RESTORE --cap-add=SETPCAP --security-opt seccomp=unconfined -p 9080:9080 liberty-to-openshift-instanton:olp-java17-1.0
85a664df916ba7fd4711cd43b6e2476f146db5fec1a21a5ebead9956a230868c
[root@localhost LibertyToOpenShiftInstantOn]#
[root@localhost LibertyToOpenShiftInstantOn]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
85a664df916b localhost/liberty-to-openshift-instanton:olp-java17-1.0 /opt/ol/wlp/bin/s... 2 minutes ago Up 2 minutes 0.0.0.0:9080->9080/tcp liberty-to-openshift-instanton
Check the logs
Issue the following command to check the logs.
podman logs liberty-to-openshift-instanton
If all goes well, youโll see a successful start using a checkpoint restore. Look for message โresumed operation from a checkpointโ.
[root@localhost LibertyToOpenShiftInstantOn]# podman logs liberty-to-openshift-instanton
[AUDIT ] Launching defaultServer (Open Liberty 24.0.0.2/wlp-1.0.86.cl240220240212-1928) on Eclipse OpenJ9 VM, version 17.0.10+7 (en_US)
[AUDIT ] CWWKT0016I: Web application available (default_host): http://85a664df916b:9080/
[AUDIT ] CWWKC0452I: The Liberty server process resumed operation from a checkpoint in 0.436 seconds.
[AUDIT ] CWWKZ0001I: Application LibertyToOpenShiftInstantOn started in 0.440 seconds.
[AUDIT ] CWWKF0012I: The server installed the following features: [el-3.0, jsp-2.3, localConnector-1.0, servlet-4.0].
[AUDIT ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 0.654 seconds.
You can optionally attach to the running container and check the logs.
I have not displayed the output from the logs. You can follow the same process as shown earlier in this post.
podman exec -ti liberty-to-openshift-instanton /bin/bash
Use curl to access the app
Test the application using curl. Review the output to check for any errors and whether a valid reply was returned.
curl -vk http://localhost:9080
Command output
[root@localhost LibertyToOpenShiftInstantOn]# curl -vk http://localhost:9080
* Trying ::1:9080...
* connect to ::1 port 9080 failed: Connection refused
* Trying 127.0.0.1:9080...
* Connected to localhost (127.0.0.1) port 9080 (#0)
> GET / HTTP/1.1
> Host: localhost:9080
> User-Agent: curl/7.76.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< X-Powered-By: Servlet/4.0
< Content-Type: text/html;charset=UTF-8
< Content-Language: en-US
< Transfer-Encoding: chunked
< Date: Tue, 13 Aug 2024 19:23:29 GMT
<
<html>
<head><title>Servlet Settings</title></head>
<body>
<h1>LibertyToOpenShift Testing - InstantOn</h1>
<table border='1'>
<tr><th>Name</th><th>Value</th></tr>
<tr>
<td>Request URL</td>
<td>http://localhost:9080/</td>
</tr>
<tr>
<td>Local Name/td>
<td>ed8ec972d72a</td>
</tr>
<tr>
<td>Remote Host/td>
<td>host.containers.internal</td>
</tr>
<tr>
<td>Server Name/td>
<td>localhost</td>
</tr>
<tr>
<td>Local addr/td>
<td>10.88.0.24</td>
</tr>
<tr>
<td>Remote addr/td>
<td>10.88.0.1</td>
</tr>
<tr>
<td>Local port/td>
<td>9080</td>
</tr>
<tr>
<td>Remote port/td>
<td>36778</td>
</tr>
<tr>
<td>Server port/td>
<td>9080</td>
</tr>
</table>
</body>
</html>
* Connection #0 to host localhost left intact
[root@localhost LibertyToOpenShiftInstantOn]#
Browse the app using a browser
Test the application using a browser.
Find the IP of your Linux server. Letโs say the IP is 10.50.12.35, issue the following in your browser.
You can try:
ifconfig -a
ip addr
After you identified the IP, open a browser and access the app. Change the IP below with your IP.
http://10.50.12.35:9080
Stop the running container
Stop the running container, then delete it.
Command | Help |
podman ps | Display the running containers |
podman ps -a | Display the running containers, including the stopped containers |
podman stop CONTAINER_ID | Stop the container with CONTAINER_ID |
podman rm CONTAINER_ID | Delete the container with CONTAINER_ID |
Display the running containers.
podman ps
Stop the running container.
podman stop liberty-to-openshift-instanton
Display all containers including any stopped containers.
podman ps -a
Delete any stopped container.
podman rm liberty-to-openshift-instanton
Command output
[root@localhost LibertyToOpenShiftInstantOn]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ed8ec972d72a localhost/liberty-to-openshift-instanton:olp-java17-1.0 /opt/ol/wlp/bin/s... 4 minutes ago Up 4 minutes 0.0.0.0:9080->9080/tcp liberty-to-openshift-instanton
[root@localhost LibertyToOpenShiftInstantOn]# podman stop liberty-to-openshift-instanton
liberty-to-openshift-instanton
[root@localhost LibertyToOpenShiftInstantOn]# podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost LibertyToOpenShiftInstantOn]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ed8ec972d72a localhost/liberty-to-openshift-instanton:olp-java17-1.0 /opt/ol/wlp/bin/s... 4 minutes ago Exited (0) 9 seconds ago 0.0.0.0:9080->9080/tcp liberty-to-openshift-instanton
[root@localhost LibertyToOpenShiftInstantOn]# podman rm liberty-to-openshift-instanton
liberty-to-openshift-instanton
[root@localhost LibertyToOpenShiftInstantOn]# podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Leave a Reply