This page demonstrates connecting to a Docker containerized application using only an administrative port and epadmin commands to send data to and receive data from the app, both manually and with a feed simulation.
See Legacy Connection to Docker Images for the related procedures to connect to a containerized app using the tradition StreamBase URI.
This page assumes:
You have the Docker for Windows or Docker for Mac client program installed and running on the host machine.
You have a Docker image available. For steps to create one from StreamBase Studio, see Creating and Running Docker Images.
See the Prerequisites section of the Creating Docker Images page for important information on the limitations and complications of the Docker for Windows product.
The Run Your App in a Docker Container section of the Creating and Running Docker Images page showed how to run a Docker image by redirecting both the StreamBase app's admin port 2000 and its StreamBase listening port 10000 to the same ports on the local machine.
The upcoming steps go back through those commands, but with an important difference. We will use the same Docker image already built, but redeploy it into a different Docker container, this time redirecting only the admin port, 2000.
The advantage of this deployment method is that it allows you to deploy multiple copies of the StreamBase application in multiple Docker containers, each with its own StreamBase port. Communication to and between these containerized apps occurs without having to know the StreamBase port of the applications in their containers.
First, determine whether you have a container running. Run either:
docker ps docker container ls
If a container with name
firstappis running the image
sample/docker_1st, stop it with either of these commands:
docker stop firstapp docker container stop firstapp
stopcommand a moment to complete. Then remove the container, using either of the following commands:
docker rm firstapp docker container rm firstapp
If you have not explicitly removed the Docker image you built in previous pages, then Docker still has the image ready for deployment. Confirm the available images using either the
docker image lscommand, and look for the image you built from the folder
REPOSITORY TAG IMAGE ID CREATED SIZE sample/docker_1st latest afc1258b7098 2 hours ago 707MB sbrt-base 10.3.0 d4dc8ddc81af 2 hours ago 707MB centos 7 49f7960eb7e4 7 days ago 200MB
Run a command like the following to name the Docker container, start it, and to map local machine port 2000 to the Docker container's port with the same number. Notice that this is the same command you ran on the Creating and Running Docker Images page, except leaving out the port 10000 redirection this time.
docker run -d --name firstapp -p 2000:2000 sample/docker_1st
Look for output similar to this:
As before, the --name firstapp argument names the Docker container as
firstapp, which is used to address the container in the next set of commands.
Confirm that your Docker container is loaded by using the
docker container lscommand.
Confirm that the Docker container is up and running the
firstappsample by using the following command:
docker logs firstapp
Look for results like the following:
[A.docker_1st] Installing node [A.docker_1st] PRODUCTION executables [A.docker_1st] File shared memory ... ... [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
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 servicetype=node
This returns the name of the node in the containerized app:
Service Name = A.docker_1st Service Type = node Network Address = dtm-adm://d71b3c306af4:2000
Use this node name as the service name in subsequent commands.
Under the security model provided with StreamBase 10.3.0 and later, newly created StreamBase Runtime nodes use a set of default security settings, if explicit settings are not defined in configuration files for the application. Those defaults are:
The application is a member of the default local authentication realm named
The realm contains one username whose name is the same as the system login name of the user who ran StreamBase Studio to create the node.
The password for this user is randomly generated.
In addition, two security roles are defined: administrator and monitor (plus a deprecated role, switchadmin, which is a legacy name for the administrator role).
These defaults balance security with ease of use for simple node-running tasks during development.
The containerized application is effectively running in a different computer with its own IP address and DNS membership. Under those circumstances, the StreamBase Runtime requires either a trusted hosts configuration or a valid name and password on the containerized app in order to connect to its streams.
However, the random password generated for your StreamBase username in the container is not known and not knowable. Therefore,
the simplest way to communicate with the containerized node is to set a new password for the default username. Do this with
a command like the following. This example shows the default username as
sbuser; substitute your own system login name in this command.
docker exec firstapp epadmin --servicename=A.docker_1st change password --username=sbuser --password=secret
(This command is shown on two lines for clarity; enter it as a single command.)
Once you have a known password for the default username, you can run epadmin commands on your host computer to communicate with the node in the container, without using the docker exec prefix. For example:
epadmin --adminport=2000 --username=sbuser --password=secret display node
Remember that you can abbreviate parameter names as long as your abbreviations remain unique for the current epadmin target. Thus:
epadmin --ad=2000 --us=sbuser --pa=secret display node
The remaining examples on this page use this abbreviated syntax.
This procedure assumes
firstapp is running in a Docker container using the default StreamBase port, 10000. On the Creating and Running Docker Images page, you ran the Docker image with a command that redirected the local machine's ports 2000 and 10000 to the Docker container's
ports 2000 and 10000. The commands on this page contact the default port 10000 as if contacting a locally running StreamBase
The commands in this section presume that you have configured a password for the containerized node's default username as
shown in the previous section. The default username is shown as
First, send manually enqueued tuples with the following steps:
To verify that you are not running a StreamBase application locally on your host machine, run
epadmin display services. The command returns silently if no services are running.
(This command might return a list of services on other machines in your local subnet. In this case, run:
epadmin display services --servicename=
clusternameis usually your system login name. See Clusters.)
Connect to the StreamBase node running in the Docker container, and run the same command prefixed with docker exec firstapp:
epadmin --ad=2000 --us=sbuser --pa=secret display services
Compare the output of the two
epadmin display servicescommands. This confirms that you are not running a StreamBase application locally but are running one in the Docker container.
In window 1, set up a dequeue for the first output stream. Run:
epadmin --ad=2000 --us=sbuser --pa=secret dequeue stream --path=BigTrades
Open another command window and set up a dequeue for the other output stream. This is window 2.
epadmin --ad=2000 --us=sbuser --pa=secret dequeue stream --path=AllTheRest
Notice that no output is produced yet. The command windows are waiting to show output from the two output streams.
Set up an enqueue to the app's input stream. Open a third command window and run:
epadmin --ad=2000 --us=sbuser --pa=secret enqueue stream
Send data manually. In window 3, send the following tuples:
Observe the following in window 1:
Tuple = IBM,4000
Tuple = MSFT,5600
And the following in window 2:
Tuple = GOOG,12000
Type Ctrl+C in window 3 to stop the enqueue processes. Leave the two dequeue command windows running as-is.
Next, run a feed simulation to enqueue tuples:
Return to StreamBase Studio, using the same workspace used in Creating Docker Images.
sample_firstappproject, navigate to
src/main/resourcesand select that folder name.
Right-click and select→ (Windows) or (macOS). This opens a new window 4 in the folder that contains the feed simulation files.
In the new window 4, run:
epadmin --ad=2000 --us=bwright --pa=secret start playback --sim=firstapp-enum.sbfs
Data now flows to the two output ports, and therefore to the two dequeue windows. Only trades with stock quantities over 10000 go to the BigTrades port dequeued in window 1.
To end the feed simulation, run:
epadmin --ad=2000 --us=bwright --pa=secret stop playback --id=0
Type Ctrl+C in windows 1 and 2 to stop the dequeue processes. Close the four windows as needed.
When done, you can stop and remove the container as described in Stop and Remove the Container in the previous page.