Testing the Service and Client Applications Locally in a Docker Setup

Prerequisites

  • Docker must be installed on your machine.
  • Access to a local Consul server.

Procedure

  1. Execute the following command on a Docker terminal to run the service application image:
    docker run -e CONSUL_SERVER_URL=consul-server-url  
    -e DOCKER_LOCAL_HOST_IP=Docker-machine-ip  
    -e DOCKER_LOCAL_HOST_PORT=Docker-machine-port -p 18086:8080 
    -e SERVICE_NAME=BWCE-HELLOWORLD-SERVICE bwce-servicediscovery.service-app
    

Note: DOCKER_LOCAL_HOST_IP: While registering service, the variable value becomes the value for IP address configured with consul service.
Note: DOCKER_LOCAL_HOST_PORT: While registering service, the variable value becomes the value for PORT configured with consul service

  1. Execute the following command on a Docker terminal to run the service application image:
    docker run -e CONSUL_SERVER_URL=consul-server-url  
    -p 18087:8080 
    -e SERVICE_NAME=BWCE-HELLOWORLD-SERVICE bwce-servicediscovery.client.app
  2. Execute the following command to view the logs to make sure that the application has started successfully.
    docker logs <container name>
    
    
  3. Check the logs for the service and client applications to make sure they have started successfully.
  4. Get the IP address for the Docker machine.
  5. Access the following URL from a browser:
    http://<docker-machine-ip>:18087

Result

The following output should be seen in the browser:
Hello from TIBCO"