Special thanks to Chris Vignola, co-author of this article.

The September 2015 Liberty Beta includes a preview of management function for Liberty Docker containers. A Liberty Docker container is a Liberty Server packaged and deployed through a Docker image. New in this beta is collective management for these containers. This is a continuation of Liberty’s embrace of Docker, which started with the publishing of a Liberty Docker image on Docker Hub.

The management functions for Liberty Docker containers in this beta include: collective registration, Admin Center visualization and operations, and phase 1 auto-scaling. Collective registration is simply the use of the collective join command to add a Liberty Docker container to a collective for management. Once a member of a collective, the Liberty Docker container is visible in the Admin Center. Status, start, and stop operations are available. Finally, you can configure the image to be scalable, using Liberty’s scaling controller feature. “Phase 1” simply means the beta auto-scaling function is limited to a subset of the full auto-scaling capability regular Liberty servers enjoy.

The following diagram depicts the workflow for building, publishing, and deploying Liberty Docker images to a collective and creating containers


beta article artwork

  1. Start by using your favorite developer tools to create your application on a Liberty server. Package and publish your app and its dependencies as a Docker image. Detailed instructions are located at the Beta Knowledge Center, including an example Dockerfile.

  2. Pull your Docker image to a Docker Host (i.e. a system that has the Docker engine running) and create a Liberty container.

  3. Join the Liberty container to the collective and bang! You can view and control your Liberty container through the Liberty Admin Center. The scripts you need to join and remove a Liberty server from the container are:

    joinMember script:

    memberHost="$(hostname -i)"
    /opt/ibm/wlp/bin/collective join defaultServer --host=$controllerHost --port=$controllerPort --user=$controllerUser --password=$controllerPassword --hostName=$memberHost --createConfigFile --keystorePassword=$memberKeystorePassword --containerName=$containerName --containerHost=$containerHost --autoAcceptCertificates
    
    
    mkdir /opt/ibm/wlp/usr/servers/defaultServer/configDropins
    mkdir /opt/ibm/wlp/usr/servers/defaultServer/configDropins/overrides
    mv /opt/ibm/wlp/usr/servers/defaultServer/c*.xml /opt/ibm/wlp/usr/servers/defaultServer/configDropins/overrides
    
    rm /opt/ibm/docker/env.properties
    echo containerName=$containerName > /opt/ibm/docker/env.properties
    echo containerHost=$containerHost >> /opt/ibm/docker/env.properties
    echo memberHttpPort=$memberHttpPort >> /opt/ibm/docker/env.properties
    echo memberHttpsPort=$memberHttpsPort >> /opt/ibm/docker/env.properties
      

    removeMember script:

    memberHost="$(hostname -i)"
    /opt/ibm/wlp/bin/collective remove defaultServer --host=$controllerHost --port=$controllerPort --user=$controllerUser --password=$controllerPassword --hostName=$memberHost --containerName=$containerName --autoAcceptCertificates
      

  4. Optionally, you can configure Liberty auto-scaling to scale out your Liberty Docker image. In this beta, only the scaling policy min and max settings control the number of containers for a given image. The join and remove scripts you used in Step 3 must be placed at /opt/ibm/docker in the Docker image and named joinMember and removeMember. The Beta Knowledge Center contains an example server.xml for the Liberty server within the container.

You can see all this in motion in the following video:

You might be wondering what this support will look like once it is generally available. While we can’t make any promises, obvious improvements would include remote deployment, phase 2 auto-scaling (i.e. metrics-based, like CPU), health management, and analytics integration.

So if managing Liberty Docker containers interests you, stay tuned and watch for what comes next!

4 comments on"Managing Liberty Docker containers (September 2015 Beta)"

  1. You can see more recent activity in this space in the February 2016 Beta at this link: https://developer.ibm.com/wasdev/blog/2016/02/17/managing-polyglot-environment-strongloop-liberty-docker-containers-liberty/

  2. Great information. I assume that the stopping and starting of liberty servers is done at the container rather than with the liberty server start command? How are old containers managed? Does the scale out feature check if the container already exists and performs a docker start as opposed to a docker run?

    Thanks

    • Good question. In this beta, scale-in or scale-out creates or destroys Docker containers, respectively. Therefore there are no unstarted auto-scaled containers, meaning each scale-out will just create a new container. Thank you.

Join The Discussion

Your email address will not be published. Required fields are marked *