EventFlow: Run and Manage with Docker Commands

This tutorial page describes how to use docker commands to run the containerized image generated on the previous page. Go through that page first if you have not already.

In this tutorial page, you will:

  • Run the containerized Docker image created on the previous page in your local Docker Desktop environment.

  • Confirm that you can communicate with the containerized application.

Run Your App in its Docker Container

The steps in this section take you through running your Docker image in its container and communicating with the EventFlow module therein.

  1. Confirm the images that are available to run with the docker images command:

    REPOSITORY   TAG      IMAGE ID         CREATED             SIZE
    docker_1st   1.0.0    5dbddbadc3e1     23 minutes ago      1.02GB
    sbrt-base    10.6.0   c39719f31fba     2 hours ago         1.02GB

    Look for the image you just built on the previous page: docker_1st.

  2. Run a command like the following to name the Docker container and start it.

    docker run -d --name firstapp -e STREAMING_NODENAME=A.cluster docker_1st:1.0.0

    You must set the STREAMING_NODENAME environment variable for the Docker image with the -e or --env option, as shown. You can specify any node and cluster names you prefer, as long as you specify the same cluster name for Docker-hosted images that will run the same fragment together as a cluster. (Do not use the same cluster name for any currently running StreamBase Application project that contains a different fragment).

    Look for output similar to this:

    d26c729222632a69b587a910f4386e5b4e71b6bf74947b0db771f139f1a8b340

    Note

    The --name argument assigns the Docker container the name firstapp. Think of this as a shortcut name or an alias. You can instead use any name you prefer.

    As an alternative, it may help you manage a cluster with many containerized modules to use the same name argument as the nodename you assign with the STREAMING_NODENAME environment variable. Thus:

    docker run -d --name A.cluster -e STREAMING_NODENAME=A.cluster docker_1st:1.0.0

    Tip

    If a message tells you your container name is in use, you can remove a leftover container with docker stop containerName followed by docker rm containerName — or just use a different name in your docker run command.

  3. Confirm that your Docker container is loaded by using the docker ps command, which returns a row like the following:

    CONTAINER ID  IMAGE             COMMAND                 CREATED        STATUS       PORTS  NAMES
    460ab35a4036  docker_1st:1.0.0  "/bin/sh -c ${STREAM…"  4 minutes ago  Up 4 minutes         firstapp
  4. Confirm that the Docker container is up and running the firstapp sample by using the following command:

    docker logs firstapp

    Look for results like the following:

    Installing application archive /var/opt/tibco/streambase/application/docker_1st-1.0.0.zip
    
    [A.cluster]     Installing node
    [A.cluster]         PRODUCTION executables
    [A.cluster]         Memory shared memory
    [A.cluster]         6 concurrent allocation segments
    [A.cluster]         Host name 8130179fbab9
    [A.cluster]         Starting node services
    [A.cluster]         Loading node configuration
    [A.cluster]         Auditing node security
    [A.cluster]         Deploying application
    [A.cluster]             Engine default-engine-for-com.tibco.sb.sample.firstapp
    [A.cluster]         Application deployed
    [A.cluster]         Administration port is 11294
    [A.cluster]         Service name is A.cluster
    [A.cluster]     Node installed
    [A.cluster]     Starting node
    [A.cluster]         Engine application::default-engine-for-com.tibco.sb.sample.firstapp started
    [A.cluster]         Loading node configuration
    [A.cluster]         Auditing node security
    [A.cluster]         Host name 8130179fbab9
    [A.cluster]         Administration port is 11294
    [A.cluster]         Service name is A.cluster
    [A.cluster]     Node started
    COMMAND FINISHED
  5. Confirm that you can connect to the StreamBase node running in the Docker container with commands like the following:

    docker exec firstapp epadmin display services
    docker exec firstapp epadmin display services servicetype=node

    The last command returns the name of the node in the containerized app:

    Service Name = A.cluster
    Service Type = node
    Network Address = dtm-adm://96b621f6a71d:2000

    Use this node name as the service name in two more commands:

    docker exec firstapp epadmin servicename=A.cluster display node
    docker exec firstapp epadmin servicename=A.cluster display engine

    Notice that the locations of resources returned by these commands are Linux paths not available on your Windows or Mac host:

    [A.cluster] Node Directory = /var/opt/tibco/streambase/node/A.cluster
    [A.cluster] Deployment Directories = /var/opt/tibco/streambase/node/A.cluster/deploy

Stopping and Removing the Container

To stop the containerized application, run either:

docker stop firstapp
docker container stop firstapp

The docker ps command does not show stopped containers. To include those, use docker ps –all.

Give the stop command a moment to complete. Next, remove the container with either:

docker rm firstapp
docker container rm firstapp

Using the Docker Desktop Dashboard

As an alternative to the docker commands shown on this page, you can use the Dashboard option from the Docker Desktop menu to open the Dashboard app. The top level of the Dashboard shows the containers currently running locally on your machine.

Select a container to see more detail, which opens to the Logs panel. Use the buttons on the top row to run basic start, stop, restart, or delete commands for the running container, and to open a shell prompt inside the container. Use the menus on the left to inspect the container's basic settings and view its statistics since startup.

Next Steps

At this point, you know how to use StreamBase Studio and Docker Desktop to containerize and run a StreamBase Application with an EventFlow fragment.

Next, try connecting to your StreamBase Application to send and receive data, described in the next page.

Note

You can configure your Docker container to redirect logging from your Docker-hosted StreamBase application to the Docker host by configuring a Logback console appender in your StreamBase application. See Docker container logging for instructions on this option.