Building a Docker Container for Batch Applications

Jobs in Control-M have a host attribute to specify the application host on which to run a job. To successfully run the job, the application host must also have a Control-M/Agent.

You can specify either a single host or a host group (that is, a logical name for a collection of hosts).

A host group is used for load balancing. When you specify a host group, Control-M directs jobs to the various hosts in the group according to their current load.

job1 {
   "host": "application_hostgroup"
   "command": "/home/user1/scripts/"
   "runAs": "user1"

For this tutorial, a container is provided. This container includes a Control-M/Agent. When running the container instance, the Control-M/Agent self-registers and is added to the host group.

When a job is defined to run on the host group, it will wait for at least one registered container in the host group before it starts to run inside the container instance.

Stopping the container unregisters the Control-M/Agent and removes the container from the host group.

Before You Begin

Ensure that you meet the following prerequisites:

  • You have successfully completed API setup, as described in Setting Up the API, and you have a valid API endpoint and API token..

  • You have a Linux account where docker is installed.

  • You have Git installed. If not, obtain it from the Git Downloads page.

  • You have local copies of the tutorial samples from GitHub and a local copy of the source code using the git clone command:

    git clone

Step 1: Building the Container Image

Go to the directory where the tutorial sample is located:

cd automation-api-quickstart/helix-control-m/102-build-docker-containers-for-batch-application/centos7-agent/

Review the docker file to see how to provision a Control-M/Agent within a docker container.

Enter the following commands on the machine to build a docker container image of Control-M. Within these commands, to generate an endpoint, specify a valid Control-M host, API endpoint, and API token.

AAPI_ENDPOINT=<tenant's API endpoint>
sudo docker build --tag=controlm \

Note that the token that you specify here is an API token, not an Agent token.

Step 2: Running a Container Instance

Type the following commands, in which CTM_HOSTGROUP is a host group name to which to add the container.

The host group name cannot contain spaces.

sudo docker run --net host \
  -dt controlm

The agent tag that you specify must have a matching agent token. For information about generating a token, see Generating an Agent Token.

Review the to see how the Control-M/Agent is registered to the host group.

Step 3: Viewing Self-registered Container Instances in Control-M

This command allows you to see that an agent with the name <docker host> was added to the list of agents. It also shows you the host group that each listed agent belongs to.

sudo docker run -i -t controlm ctm config server:agents::get IN01

Step 4: Running a Simple Job Flow in the Docker Container

View the JobsRunOnDockerSample.json file to see what the output of the command is inside the container.

Edit the file ../JobsRunOnDockerSample.json and replace "Host": "<HOSTGROUP>"with the host group name created in Step 2.

Run the jobs in the docker container:

sudo docker run -v $PWD:/src -i -t controlm ctm run /src/JobsRunOnDockerSample.json

This command enables you to inspect how the jobs run inside the container:

sudo docker run -i -t controlm ctm run status <runid>

Step 5: Decommissioning the Container Instance

To remove and un-register the container Control-M/Agent from the host group and Control-M, type the following command:

sudo docker exec -i -t <docker id> /home/controlm/
sudo docker stop <docker id>