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

healthcheck does not pass/return causing `docker compose up --wait` to wait forever #417

Closed tigerinus closed 9 months ago

tigerinus commented 1 year ago

Use the docker-compose.yml suggested in README.md (or build a custom one - doesn't matter because it's an issue caused by container)

Then run docker compose up --wait in the path.

Expect: OpenHAB should be up and running in a healthy state

Actual: It waits forever...

docker compose up --wait
[+] Running 7/7
 ⠿ openhab Pulled                                                                                                             48.8s
   ⠿ bb263680fed1 Pull complete                                                                                               12.5s
   ⠿ 269f6a0092c7 Pull complete                                                                                               39.5s
   ⠿ 396b1d4e3e2d Pull complete                                                                                               44.4s
   ⠿ 31a2a56a6096 Pull complete                                                                                               47.2s
   ⠿ de5f82bdb506 Pull complete                                                                                               47.3s
   ⠿ c58db1d12c8d Pull complete                                                                                               47.4s
[+] Running 0/1
 ⠿ Container openhab-openhab-1  Waiting                                                                             
[+] Running 0/1                                                                                                   22
 ⠿ Container openhab-openhab-1  Waiting                                                                       24.9s

Let's look at some other docker compose, like this one:

https://github.com/docker/awesome-compose/tree/master/wordpress-mysql

docker compose up --wait
[+] Running 2/2
 ⠿ Container wordpress-mysql-db-1         Healthy                                                   0.5s
 ⠿ Container wordpress-mysql-wordpress-1  Healthy                                                   0.5s

This is what's expected: The container should be in healthy state and --wait returns.

wborn commented 1 year ago

It'll stay in "starting" and becomes "healthy" after 5 minutes, see the HEALTHCHECK in the Dockerfile:

https://github.com/openhab/openhab-docker/blob/781ef914ab22099df7eaf789d53565f2170fa53c/debian/Dockerfile#L101

That's because on slow SBCs startup can take several minutes and it would then endlessly restart the container during startup causing it never to become healthy.

You can reconfigure the healthcheck behavior in your compose file if you are using faster hardware, see:

https://docs.docker.com/compose/compose-file/#healthcheck

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.