Step 8 – Start the API Gateway Docker container

Use the docker run command to start the API Gateway container. For example:

$ docker run -d --name=apimgr --network=api-gateway-domain
  -p 8075:8075 -p 8065:8065 -p 8080:8080 
  -v /tmp/events:/opt/Axway/apigateway/events 
  -e EMT_ANM_HOSTS=anm:8090 -e CASS_HOST=casshost1 
  -e METRICS_DB_URL=jdbc:mysql://metricsdb:3306/metrics?useSSL=false 
  -e METRICS_DB_USERNAME=root -e METRICS_DB_PASS=my_db_pwd 
   api-gateway-my-group:1.0

This example performs the following:

  • Starts an API Manager-enabled container from an image named api-gateway-my-group:1.0. You must specify the name of the API Gateway Docker image that you created in Step 7 – Create an API Gateway Docker image.
  • Runs the container in the background using the -d option.
  • Binds the default traffic port 8080 of the container to port 8080 on the host machine, which enables you to test the API Gateway on your host machine.
  • Mounts the /tmp/events host directory in the container using the -v option. This directory contains API Gateway transaction event logs. For more details, see Mount volumes to persist logs outside the API Gateway container.
  • Uses environment variables to specify connection details for the metrics database and the Apache Cassandra host used to store the API Manager data.
  • Sets the EMT_ANM_HOSTS environment variable to anm:8090 in the container. This enables the API Gateway to communicate with the Admin Node Manager container on port 8090. The API Gateway is now visible in the API Gateway Manager topology view. For example:

API Gateway container in topology view

Mount volumes to persist logs outside the API Gateway container

You can persist API Gateway trace and event logs to a directory on your host machine. For example, run the following docker run command to start an API Gateway container from an image named api-gateway-my-group:1.0 and mount volumes for trace and event logs:

$ docker run -it -v /tmp/events:/opt/Axway/apigateway/events 
-v /tmp/trace:/opt/Axway/apigateway/groups/emt-group/emt-service/trace 
-e EMT_ANM_HOSTS=anm:8090 -p 8080:8080 --network=api-gateway-domain api-gateway-my-group:1.0

This example starts the API Gateway container and writes the trace and log files to /tmp/events and /tmp/trace on your host machine. The trace and log files contain the container ID of the API Gateway container in the file names.

Note   To enable an Admin Node Manager container to process the event logs from API Gateway containers, you must run the Admin Node Manager container with the same volume mounted. For more details, see Create a metrics-enabled Admin Node Manager image and Start a metrics-enabled Admin Node Manager container.

Start a deployment-enabled API Gateway container in a development environment

The following simple example sets the EMT_DEPLOYMENT_ENABLED environment variable to true to enable you to deploy configuration directly from Policy Studio to the running API Gateway container:

$ docker run -d -e EMT_DEPLOYMENT_ENABLED=true -e EMT_ANM_HOSTS=anm:8090 
-p 8080:8080 --network=api-gateway-domain api-gateway-my-group:1.0
Caution   The EMT_DEPLOYMENT_ENABLED environment variable is provided as a convenience for development environments only:
  • Do not set EMT_DEPLOYMENT_ENABLED=true on production systems. In production environments, to deploy changes in API Gateway configuration, you must export a .fed file from Policy Studio, rebuild the API Gateway Docker image, and restart the API Gateway Docker container.
  • The EMT_DEPLOYMENT_ENABLED=true setting only enables you to deploy changes to a running container from Policy Studio. You cannot deploy changes using the API Gateway Manager, managedomain, or projdeploy tools.

Related Links