Home:ALL Converter>How to do a health-check to Spring Boot app running inside Windows Docker Windows Container with Ansible?

How to do a health-check to Spring Boot app running inside Windows Docker Windows Container with Ansible?

Ask Time:2017-02-23T19:31:56         Author:jonashackt

Json Formatter

I want to provision a Spring Boot app into a Windows Docker Container which is hosted on a Windows Docker Host (which is virtualized on a Mac, but this is another story ;) ) with Ansible. I already successfully used Ansible Windows Modules to provision a Spring Boot app to Windows.

I´am in the final chapter and just wanted to add a health-check at the very end. As outlined in the blogpost without Docker this is easy:

  - name: Wait until our Spring Boot app is up & running
    win_uri:
      url: "http://localhost:8080/health"
      method: GET
    register: result
    until: result.status_code == 200  
    retries: 5
    delay: 5

Now with Docker Windows Containers there´s a known limitation so that you can´t use localhost for now. We have to use the Windows Docker Containers internal Hyper-V IP address (you can see the IP after you ran a docker inspect <yourContainerIdHere> inside the JSON output in NetworkSettings.Networks.nat.IPAddress).

My question is: How can I obtain the Windows Docker Container´s Hyper-V internal IP address, output it inside a debug statement and do a health-check similar to the one I outlined?

Author:jonashackt,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/42414584/how-to-do-a-health-check-to-spring-boot-app-running-inside-windows-docker-window
yy