Create container application images

A container image is a layered executable software package used to build and run a containerized application. We can use a WebSphere Liberty container image to build an application image.


Steps

  1. Choose a base container image.

    We can choose from several preconfigured Liberty container images. The kernel tag provides a minimum server. We can include features on the server for the application by including the RUN features.sh command. Liberty features are downloaded from the Maven Central repository by default.

      remoteRepo.url=https://my-remote-server/secure/maven2
      remoteRepo.user=operator
      remoteRepo.password={aes}KM8dhwcv892Ss1sawu9R+

    We can specify alternatives using the file...

      /opt/ibm/wlp/etc/featureUtility.properties

  2. Set up a Dockerfile template for the application image.

    The following example Dockerfile template specifies the kernel-java8-openj9-ubi WebSphere Liberty container image in the FROM directive.

      FROM icr.io/appcafe/websphere-liberty:kernel-java8-openj9-bi

      # Default setting for the verbose option. Set it to true to debug the application container image build failures
      ARG VERBOSE=false

      # Add Liberty server configuration including all necessary features
      COPY --chown=1001:0 server.xml /config/

      # Modify feature repository (optional)
      COPY --chown=1001:0 featureUtility.properties /opt/ibm/wlp/etc/

      # This script will add the requested XML snippets to enable Liberty features and grow the image to be fit-for-purpose using featureUtility.
      RUN features.sh

      # Add interim fixes (optional)
      COPY --chown=1001:0 interim-fixes /opt/ibm/fixes/

      # Add application COPY --chown=1001:0 Sample1.war /config/dropins/

      # This script will add the requested server configurations, apply any interim fixes and populate caches to optimize runtime RUN configure.sh

    A template like this creates an image that adds a single application and the corresponding configuration. Do not configure the container manually after it is started, except for debugging purposes. Configuration changes made to the container are not reflected in new containers created from the image.

We now have a container image containing both the application and its configuration, which means we can create new, fully configured containers at any time.

Parent: