openhab / openhab-docker

Repository for building Docker containers for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
209 stars 128 forks source link

Added healthcheck in alpine and debian dockerfile #351

Closed MathiasVDA closed 3 years ago

MathiasVDA commented 3 years ago

Hello, I hope this is wanted. I haven't found any reference to health checks in the repo nor in the openhab discussion forum. I did find one compose file that implemented the healthcheck with the docker run command. But I though it's best to directly implement it in the official dockerfiles. I successfully tested the debian version on a raspberry pi.


This change is Reviewable

MathiasVDA commented 3 years ago

I see the DCO check on this pull request failed with the mention that the commit was not correctly signed off. I'm not sure why, I copied the line from the readme and changes as required.

I reviewed the past commits and noticed that the github_handle is missing. Now the question is, is the documentation in need of a patch or is the check itself? :)

xanderificnl commented 1 year ago

I was confused as to why OpenHAB wasn't working while the logs said it was listening and I could curl inside the container. Outside the container, curl reported connection refused. Another thing that seemed odd was that docker reported the container was starting. Once I returned from a quick coffee break, docker had gone to green and OpenHAB was accessible.

A quick dig through docker inspect made me realize Docker isn't port forwarding until the service is reported healthy. I'm guessing people haven't noticed this because they're using net=host which bypasses Docker's proxy.

Seeing as the healthcheck has a relatively high interval, I updated my openhab.yml to:

version: '3.3'
services:
    openhab:
        healthcheck:
          interval: 5s
          retries: 1000

Perhaps a note in the documentation for newcomers such as me would be nice, or a lower interval & higher retries.