Creating container application images

A container image is a layered executable software package that contains everything you need to build and run a containerized application. You can use a WebSphere® Liberty container image to build an application image that meets your development needs.

Procedure

  1. Choose a base container image.

    You can choose from several preconfigured Liberty container images.

    The kernel tag provides a minimum server. You can include features on your server for your application by including the RUN features.sh command. Liberty features are downloaded from the Maven Central repository by default. You can specify alternatives by using the /opt/ibm/wlp/etc/featureUtility.properties file.
    remoteRepo.url=https://my-remote-server/secure/maven2
    remoteRepo.user=operator
    remoteRepo.password={aes}KM8dhwcv892Ss1sawu9R+

    For more information about features, see Repository and proxy modifications.

  2. Set up a Dockerfile template for your 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-ubi
    
    # 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 that you make to the container are not reflected in new containers that are created from the image.

Results

You now have a container image that contains both your application and its configuration, which means that you can create new, fully configured containers at any time.