Apama 10.3 | Apama Documentation | Deploying and Managing Apama Applications | Deploying Apama Applications with Docker | Deploying an Apama application in Docker
 
Deploying an Apama application in Docker
The examples below reference the image in the Docker Store. However, you can also use an image built from your Apama installation; the results will be the same.
The base image simply provides an empty running correlator, with the management port exposed. You can use the command line tools described in Correlator Utilities Reference to inject EPL and manage the correlator, or you can connect to the running container and use the management commands within the container. The expected use case is the deployment of a user application in an image derived from the base image.
1. Typically, the first step is to create the Dockerfile that references the required image of the Apama correlator. The following is an example Dockerfile:
# Reference the Apama image at store/softwareag/apama-correlator:<TAG>.
# The tag refers to the version number of the Apama correlator.
FROM store/softwareag/apama-correlator:version
 
# Copy files from the local app directory to /app in the resulting image.
COPY --chown=sagadmin:sagadmin app/* /app/
 
# This is the command we run - it references the internal directory.
CMD ["correlator","--config","/app"]
The above example file produces an image that contains a root level directory called /app that has copies of local files in it. These files will be owned by the user the correlator runs as, called sagadmin.
2. When the correlator image runs, it is directed to read the configuration file init.yaml that is present within the directory. An example of this from the Simple sample application is shown below. It can be found in the samples/docker/applications/Simple directory of your Apama installation, along with the HelloWorld.mon file that it references.
Example init.yaml:
correlator:
initialization:
list:
- ${PARENT_DIR}/HelloWorld.mon
At correlator startup, the above configuration file injects the monitor file HelloWorld.mon from the same directory. The image build process will copy the HelloWorld.mon and init.yaml files into the image. Thus, the application image can run without outside dependencies.
3. You build the image using the docker build command. The following example assumes that the command is run from the directory containing the Dockerfile. See the Docker documentation for details on the available options.
docker build --tag organization/application .
4. Once the image is built, it is stored locally. You can view it using the docker images command. Note that the image is not running at this point.
docker images | grep application
5. To run the image as a container, enter the following command:
docker run -d --rm --name container organization/application
The options -d and --rm are used to detach and remove the container after shutdown.
6. To examine the running process, enter the following command:
docker ps
7. To examine the logs, enter the following command:
docker logs container
8. To stop the container, enter the following command:
docker stop container
Now the docker ps command should no longer show your container.
9. To remove the image, enter the following command:
docker rmi organization/application
This untags and deletes the image.
Note that the application is "baked" into the image you create. The files copied into the image will not change and any output will not persist outside the container. The management port is exposed, and therefore the correlator can be manipulated remotely through the Management interface (see also Using the Management interface). However, you can interact with the running container in many ways, including starting a shell, examining logs, and running commands in the container. See the Docker documentation for details on the available options.

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.