You can register IBM WebSphere Liberty servers that are running on Docker with
Bluemix®
Product Insights to report server registration
and usage and other information, such as number of active WebSphere Liberty servers, host location of each server,
product edition and version of each server, and how busy each server is.
Before you begin
IBM Cloud
Product Insights requires WebSphere Application
Server Liberty version 17.0.0.1 or later.
The Liberty Docker builds include a pull
of the most recent version of the WebSphere Liberty Docker image from Docker hub. The Liberty Docker Hub images include an ILAN
license, meaning that they are no-cost, non-supported, and non-warranted versions of the product. To
update the license to a supported product, see Upgrading
the image from Docker Hub to a production image.
Before you connect an IBM WebSphere Liberty server instance to Product Insights, you
must have an IBM Cloud account and create
the service in an organization and space. Follow the getting started steps to set up an account and
allocate the Product Insights service. Make a
note of the API host and API key that is described in the
instructions.
Configuring your WebSphere Liberty servers
on Docker requires either a Linux machine or a virtual machine with Docker installed.
Note: Configuring Liberty within a Kubernetes
environment requires a similar approach as dynamically adding IBM Cloud
Product Insights. You can create Kubernetes
secrets or configuration maps that contain the productInsights.xml and
digicert.jks files and mount those files to the running Docker image by
specifying the mount points in the applications deployment YAML file.
About this task
After you define the Liberty collective
and create the Docker image in a Docker container, use the Deploy tool to install the image on a
Docker host within the collective.
Procedure
- Build the Docker image.
- To override a default value in the Liberty server configuration, rename the existing server.xml file, you can create
and configure a new server.xml file. Product Insights is enabled dynamically and does
not require any additional Product Insights
configuration. The following server configuration is included in the
websphere-liberty:webProfile7 Docker
image.
<server>
<featureManager>
<feature>webProfile-7.0</feature>
</featureManager>
<!-- To allow access to this server from a remote client host="*" has been added to the following element -->
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="9080"
httpsPort="9443" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
</server>
- Create an installation Dockerfile. In the same directory as the server.xml file, create a Dockerfile that
installs the productInsights-1.0
Liberty feature.
FROM websphere-liberty:webProfile7
COPY server.xml /config
RUN installUtility install --acceptLicense productInsights-1.0\
&& rm -rf /output/workarea /output/logs
If
you did not create your own server.xml file in step 1, then you remove or
comment out the following line:COPY server.xml /config
- Build the Docker image. Build the Docker image by running the docker build command. The machine that you build the
Docker image from must have access to the internet because it needs to download the Liberty Docker image and the
productInsights-1.0
Liberty
feature.
docker build -t liberty-product-insights-example
- Run the image in a Docker container.
- Run an instance of the Docker image. To run an instance of the Docker image, use the name of the application that is hosted on the
Liberty server container. The following
example illustrates the best practice for
naming.
docker run -d --volume=/opt/docker/libertyConfig:/config/configDropins/overrides -e CONTAINER_HOST=' myApplication' liberty-product-insights-example
Note: The
default host name that is reported to Product Insights for the running server instance is
the container name, which is reassigned each time a Docker image is run or scaled. To be able to
consistently track metrics for a server, you must override the default host name value by setting a
value for the CONTAINER_HOST environment variable.
- Run multiple instances of the Docker image. To run multiple instances of the Docker image for the same application, use the same value for
CONTAINER_HOST for each instance. When registration and usage data that
corresponds to the CONTAINER_HOST is sent to the Product Insights service, the service combines the
information as if it came from a single instance so that you can see all usage that is associated
with the application.
Note: To optionally override the server name, set the
CONTAINER_NAME environment variable. If this variable is not set, all images
report
defaultServer as the server name to the
Product Insights
Service.
docker run -d --volume=/opt/docker/libertyConfig:/config/configDropins/overrides -e CONTAINER_HOST=' myApplication' -e CONTAINER_NAME=' myServerName' liberty-product-insights-example
- Dynamically add IBM Cloud
Product Insights configuration.
- Download the IBM Cloud copy of the
digicert.jks certificate file and place it in the
/opt/docker/libertyConfig directory.
- In the same directory, create a configuration file named
productInsights.xml. Substitute <apiHost> with the API
host and <apiKey> with the API key for your service.
<server>
<featureManager>
<feature>productInsights-1.0</feature>
</featureManager>
<productInsights url="<apiHost>" apiKey="<apiKey>" sslRef="productInsightsSSL"
groups="DockerImages"/>
<keyStore id="productInsightsKeyStore" location="/config/digicert.jks" type="JKS"/>
<ssl id="productInsightsSSL"
keyStoreRef="productInsightsKeyStore"
trustStoreRef="productInsightsKeyStore"
sslProtocol="TLSv1.2"/>
</server>
Note: If the machine that runs the Docker container connects to the
Product Insights service through a gateway or proxy
server, the configuration is slightly different. For more information, see
Use a gateway or proxy server.
- Verify registration with IBM Cloud
Product Insights.
- Find the container ID by running the docker ps command.
docker ps
- Attach STDIN to the Docker container through bash so that you can interact with the Docker
container file system.
docker exec -it <containerId> bash
- Verify that the server was registered with the Product Insights service by checking the Liberty logs. In the /logs directory, open the messages.log file
and look for the following
message.
CWWKR0400I: The server was registered with the IBM Cloud Product Insights service on the specified URL <apiHost>.
- In your browser, go to your Product Insights service dashboard on IBM Cloud to view
the newly registered server.
Results
Your IBM WebSphere Liberty servers that
are running on Docker with IBM Cloud
Product Insights are registered to support
server registration and usage.