Query stub information in Docker images and containers

After you build a Docker image, you can query that image to see stub information such as the stub name, its ID, and its exposed port. In addition, after the image is running as a container, you can query the container to retrieve information as to what stubs are running within it.

Docker images

The Docker images that are built from a Dockerfile and build context files that are published from Rational® Integration Tester contain a file that is named stubs.info with basic information for the stubs that are included. To view the file contents within the image, use this Docker command:
docker run --entrypoint cat stubimage /stubs.info
where stubimage is the name(tag) for the stub image. An example of the output follows:
NAME    ID                          EXPOSED_PORT
myStub  1f8b3e1a:150a97ea022:-7cdb  8081

Docker containers

To query stub information when the image is running as a container, from the docker host, you can use the curl command:
curl http://<container_ip>:7820
where <container_ip> is the IP address of the container, not the host. To get the IP address of the container, use this Docker command:
docker inspect -- format '{{.NetworkSettings.IPAddress}}' <container_id>
The port 7820 is used by default. If you want to, you can override this port assignment when you run the container by specifying an environment variable named STUB_INFO_PORT. For example, add the -e option with this environment variable to the docker run command:
-e STUB_INFO_PORT=8140
The output of the query is text in JSON format. An example of output follows:
{
    "stubs": [
        {
            "id": "1f8b3e1a:150a97ea022:-7cdb",
            "name": "myStub",
            "activities": [
                {
                    "exposedPort": "8081",
                    "rule": "Path: /test AND Port: 80 AND Method: POST AND (Host: www.example.com OR Host: 93.184.216.34 OR (source host=93.184.216.34 AND (Host: localhost OR Host: 127.0.0.1 OR Host: 0:0:0:0:0:0:0:1)))"
                }
            ],
            "started": "true"
        }
    ]
}