Alex
Alex

Reputation: 791

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.

Upvotes: 0

Views: 1486

Answers (1)

Gas
Gas

Reputation: 18030

There are several potential issues with your container:

  1. You are using kernel image which doesnt include any features, so your server.xml would need to specify features you need e.g.
    <!-- Enable features -->
    <featureManager>
        <feature>jsp-2.3</feature>
    </featureManager>
  1. 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

  1. If you want to use <webApplication.. then your application should be put to apps folder, NOT dropins like 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.

Upvotes: 2

Related Questions