This tutorial describes how to use StreamBase Studio to build a Docker image from a StreamBase application, and deploy the image to Docker. Docker is a third-party application used to create, deploy, and run applications by using containers of information across a network or the cloud. Describing Docker is beyond the scope of this document. Docker usage can be found on its website.
In this tutorial, you will:
Load a StreamBase project
Build a Docker Image
Start and test your image
Create and run a Docker container, exposing local ports to the running Docker container
Docker for Windows or Docker for Mac from store.docker.com must be installed and currently running for these steps to succeed. Other Docker desktop solutions may work, but are not supported by StreamBase Studio.
Docker for Windows installs Microsoft Hyper-V as its virtual machine hosting solution. On some Windows 10 machines, there can an incompatibility between Hyper-V and the StreamBase Runtime on the host. The symptom is that more than one node installed by the StreamBase Runtime on the Windows host (not in Docker) do not stay running. If you encounter this issue, see this troubleshooting page.
From StreamBase Studio, select→
In the Load Sample Projects dialog, type
firstinto the type filter text search text box, then select the
Getting Started Guide tutorialsearch result, and click to load the project.
It may take some time for Studio to build the loaded project the first time as it resolves and copies Maven dependencies. The project is ready when there are no red X's in the Project Explorer view.
Create an EventFlow Fragment archive for
firstapp. In the Project Explorer view, select the sample_firstapp project folder.
Right-click and select→ from the context menu. Look for a Build Success message in the Console view.
[INFO] ----------------------------------------------- [INFO] BUILD SUCCESS [INFO] ----------------------------------------------- [INFO] Total time: 04:40 min [INFO] Finished at: 2017-10-06T10:26:52-04:00 [INFO] Final Memory: 45M/545M [INFO] -----------------------------------------------
Create a StreamBase Application project that will generate the Docker container. Select→ → .
In the StreamBase Project dialog, enter a project name. This example uses
Select the StreamBase Application option and click Next.
In the Configure Maven Artifact dialog, change the value of the Group ID to
com.tibco.sb.sample. Click .
Optional. In the Archetype Properties dialog, change the
Ato reduce the number of test instances created.
buildDockerfrom false to
Clickand when prompted.
In the New StreamBase Project Created dialog, check the Do not show this again check box and click . A new project named docker_1st is created under the Project Explorer.
pom.xmlfile to add the firstapp EventFlow fragment dependency. Right click the docker_1st folder and select → .
In the Add Dependency Dialog, type
firstappin the Enter groupId filter box.
Select com.tibco.sb.sample_firstapp from the Search Results and click .
Build the Docker image as follows:
In the Project Explorer view, select and right-click the
docker_1stfolder, then select → (DOTS are important).
In the Run Configuration dialog:
In the Goals field, enter
Select the Skip Tests check box.
Make sure your Docker for Windows or Docker for Mac client is now running.
Click, then click .
Look for a BUILD SUCCESS message in the Console view.
C:\Users\sbuser\Documents\DockerWorkspace\sample_firstapp>docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE sample/docker_1st latest 15c55aedb6eb 34 seconds ago 868MB centos 7 196e0ce0c9fb 6 weeks ago 197MB
Create a Docker Container, run it, and expose ports to Docker.
Confirm what images are available to run by entering the
docker image lscommand:
C:\Users\sbuser\Documents\DockerWorkspace\sample_firstapp\target>docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE sample/docker_1st latest 15c55aedb6eb 10 minutes ago 868MB centos 7 196e0ce0c9fb 6 weeks ago 197MB
You should see the image you just built:
sample/docker_1st. You need the string,
sample/docker_1st, to add to the end of the command in the next step. This example shows
sample/docker_1stas the image name, but the
sampleportion of this path may be different, depending on the Group ID you specified when creating the StreamBase Application project. TIBCO suggests using com.tibco.sb.sample, and Docker uses the last portion of this Group ID as the folder name. If you used a different Group ID, the path will match accordingly. Use the image name shown in the output of docker image ls.
Run this command to name the Docker container, start it, and expose ports:
docker run –d --name firstapp –p 2000:2000 –p 10000:10000 sample/docker_1st.
You should see output similar to this:
--name firstapp names the Docker container as
firstapp. Think of this as a shortcut name or an alias. You can use whatever name you want.
If your container name is in use, you will see an
already in usemessage. To remove a named container, run:
docker rm <containerName>or just use another name in your docker run command.
Check that the Docker container is up and running
docker logs firstapp.
C:\Users\sbuser\Documents\DockerWorkspace\sample_firstapp\target>docker logs firstapp [A.docker_1st] Installing node [A.docker_1st] PRODUCTION executables [A.docker_1st] File shared memory [A.docker_1st] 2 concurrent allocation segments [A.docker_1st] Host name d26c72922263 [A.docker_1st] Container tibco/sb [A.docker_1st] Starting container services [A.docker_1st] Loading node configuration [A.docker_1st] Auditing node security [A.docker_1st] Deploying application [A.docker_1st] Engine default-engine-for-com.tibco.sb.sample.firstapp [A.docker_1st] Application deployed [A.docker_1st] Administration port is 2000 [A.docker_1st] Discovery Service running on port 54321 [A.docker_1st] Service name is A.docker_1st [A.docker_1st] Node installed [A.docker_1st] Starting node [A.docker_1st] Engine application::default-engine-for-com.tibco.sb.sample.firstapp started [A.docker_1st] Loading node configuration [A.docker_1st] Auditing node security [A.docker_1st] Host name d26c72922263 [A.docker_1st] Administration port is 2000 [A.docker_1st] Discovery Service running on port 54321 [A.docker_1st] Service name is A.docker_1st [A.docker_1st] Node started COMMAND FINISHED
Connect to the Docker node running in the Docker container with the following command:
epadmin adminport=2000 username=guest password=guest display node
You should see results similar to the following:
Node Name = A.docker_1st Node Description = No description Node State = Started Host Name = d26c72922263 Administration Port = 2000 Discovery Service = running on port 54321 Container = tibco/sb Node Directory = /var/opt/tibco/A.docker_1st Deployment Directories = /var/opt/tibco/A.docker_1st/deploy Install Time = 2017-10-26 19:13:00 +0000 UTC Last Start Time = 2017-10-26 19:13:07 +0000 UTC Build Type = PRODUCTION Product Version = TIBCO StreamBase Runtime 10.2.0 (build 1710231209) Product Installation Directory = /opt/tibco Web Server State = Started Web Server URLs = http://d26c72922263:33633
Compare the output shown above to the output shown below by running the
epadmin display servicescommand. The output from these commands is just to verify there are no StreamBase services running locally on your machine. However, there are StreamBase services running in your Docker container.
After successfully creating and running a Docker image, try connecting to your Docker-hosted StreamBase Application to send and receive data. See Running Docker Images Tutorial for more information.