'How to containerize an application with websphere-liberty image
I'm trying to containerize an application with websphere-liberty image
In my project i have a Dockerfile like this:
FROM websphere-liberty:kernel
COPY --chown=1001:0 target/demo-1.0-SNAPSHOT.war /config/dropins/verificaciones/
COPY --chown=1001:0 src/main/config/server.xml /config/
RUN configure.sh
my server.xml is this:
<server description="Sample Liberty server">
<variable name="default.http.port" defaultValue="9080"/>
<variable name="default.https.port" defaultValue="9443"/>
<webApplication location="demo-1.0-SNAPSHOT.war" contextRoot="/srp-verificaciones" />
<httpEndpoint host="*" httpPort="9080" httpsPort="-1"/>
</server>
later i run this commands:
$ docker build -t app .
$ docker run -d -p 8080:9080 app
but i get no response.
is just a servlet with a hello world.
what am i missing?
thanks for your help.
Solution 1:[1]
There are several potential issues with your container:
- You are using
kernelimage which doesnt include any features, so yourserver.xmlwould need to specify features you need e.g.
<!-- Enable features -->
<featureManager>
<feature>jsp-2.3</feature>
</featureManager>
- If you use dropins then you need to put war file into that directory not subdirectory, so your dockerfile should have entry like this (without /verificaciones/):
COPY --chown=1001:0 target/demo-1.0-SNAPSHOT.war /config/dropins
and if you use dropins and dont have ibm-web-ext.xml file in your WEB-INF folder, then app is deployed on the context-root based on your file name - in this case /demo-1.0-SNAPSHOT
In this case also you CANNOT have <webApplication ... entry in your server.xml
- If you want to use
<webApplication..then your application should be put toappsfolder, NOTdropinslike this:
COPY --chown=1001:0 target/demo-1.0-SNAPSHOT.war /config/apps
and in this case you can access your app by context root defined in that tag. More details here https://www.ibm.com/docs/en/was-liberty/base?topic=deploying-applications-in-liberty
So clean up your dockerfile, and if you still have issues, add full server.xml and logs from starting the server.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gas |
