Resolve container status unhealthy in docker compose ps#2257
Conversation
|
@leehyeoklee Thank you for the contribution. :) I agree that the unhealthy status shown in docker ps needs to be improved. However, I would like to suggest a different approach, as I hope to avoid adding such a long and complex command for health checks in docker-compose.yaml. What if we add curl to the Dockerfile and change the base OS from Ubuntu to an appropriate Alpine? This could help resolve the health check issue while also reducing the container image size. Could you first check whether CB-Tumblebug works correctly after changing the base OS image? https://github.com/cloud-barista/cb-tumblebug/blob/main/Dockerfile#L33 |
|
There were additional changes needed in the process of changing the base OS image. Changed base image: Package Manager Update: from Issue Encountered: Root Cause: Solution: |
|
@leehyeoklee Thanks for the suggestion. I agree with disabling CGO so that containers utilize static linking (using native Go lib only) In addition, please change the current build base of the Dockerfile to alpine so we can reduce container size for both build and runtime. (+ enable curl for runtime docker) |
38218a5 to
c38404b
Compare
seokho-son
left a comment
There was a problem hiding this comment.
LGTM!! I've tested it as well and it works. :)
Thanks @leehyeoklee for the contribution.
|
/approve |
|
@all-contributors please add @leehyeoklee for User Testing |
|
I've put up a pull request to add @leehyeoklee! 🎉 |

Summary
Replace curl-based healthcheck with bash built-in TCP socket check to eliminate curl dependency
Problem
Previously, even when all services were functioning correctly, running
docker compose pswould show CB-Tumblebug and CB-Spider containers asunhealthy.This was caused by the healthcheck command failing due to
curlnot being installed in the container environment where the healthcheck runs.Motivation
The previous healthcheck implementation relied on the
curlcommand, which caused healthcheck failures in environments wherecurlis not installed.To resolve this issue, I've replaced it with bash's built-in TCP socket feature (
/dev/tcp), eliminating external dependenciesChanges
curl -f http://localhost:1323/tumblebug/readyzto HTTP GET request using bash TCP socketcurl -f http://localhost:1024/spider/readyzto HTTP GET request using bash TCP socketRationale
Installing curl in the container image would add unnecessary overhead and increase the image size. Instead, this PR leverages bash's built-in
/dev/tcpfunctionality to perform healthchecks against the existing readyz endpoints. This approach is more lightweight and eliminates the external dependency on curl while maintaining the same functionality.Benefits
unhealthystatus indocker compose pscurl) dependencyTesting
docker compose psshows containers ashealthywhen services are running