Skip to content

Resolve container status unhealthy in docker compose ps#2257

Merged
cb-github-robot merged 3 commits intocloud-barista:mainfrom
leehyeoklee:fix-healthcheck-curl-dependency
Jan 11, 2026
Merged

Resolve container status unhealthy in docker compose ps#2257
cb-github-robot merged 3 commits intocloud-barista:mainfrom
leehyeoklee:fix-healthcheck-curl-dependency

Conversation

@leehyeoklee
Copy link
Copy Markdown
Contributor

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 ps would show CB-Tumblebug and CB-Spider containers as unhealthy.

Image

This was caused by the healthcheck command failing due to curl not being installed in the container environment where the healthcheck runs.

Image

Motivation

The previous healthcheck implementation relied on the curl command, which caused healthcheck failures in environments where curl is not installed.

prev

To resolve this issue, I've replaced it with bash's built-in TCP socket feature (/dev/tcp), eliminating external dependencies

now

Changes

  • CB-Tumblebug healthcheck: Changed from curl -f http://localhost:1323/tumblebug/readyz to HTTP GET request using bash TCP socket
  • CB-Spider healthcheck: Changed from curl -f http://localhost:1024/spider/readyz to HTTP GET request using bash TCP socket

Rationale

Installing curl in the container image would add unnecessary overhead and increase the image size. Instead, this PR leverages bash's built-in /dev/tcp functionality 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

  • ✅ Fixes the incorrect unhealthy status in docker compose ps
  • ✅ Eliminates external tool (curl) dependency
  • ✅ Enables lighter container images

Testing

  • Confirm that docker compose ps shows containers as healthy when services are running
Image

@seokho-son
Copy link
Copy Markdown
Member

@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

@leehyeoklee
Copy link
Copy Markdown
Contributor Author

There were additional changes needed in the process of changing the base OS image.

Changed base image: ubuntu:22.04alpine:3.19

Package Manager Update: from apt-get to apk
There seems to be no major issues with this change.

Issue Encountered:
When I changed the base image to Alpine and initially tried to run the container, it failed with:

exec /app/src/cb-tumblebug: no such file or directory

Root Cause:
Alpine uses musl libc while the Go binary built on Debian (golang:1.25.0-bookworm) expects glibc. The dynamic linking caused the runtime to fail.

Solution:
When I used static linking through build options, I confirmed that Tumblebug's health check shows as healthy. What do you think about proceeding with this approach?

@seokho-son
Copy link
Copy Markdown
Member

@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)

@leehyeoklee leehyeoklee force-pushed the fix-healthcheck-curl-dependency branch from 38218a5 to c38404b Compare January 10, 2026 05:42
@leehyeoklee
Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've completed all the requested changes:

  • CGO is disabled for static linking
  • Changed build base to Alpine (golang:1.25.0-alpine)
  • Enable curl for runtime docker

I have not applied any image-related changes to Spider, so I have only confirmed that Tumblebug itself is healthy and appears to be working correctly.

image

Please review and verify!

Copy link
Copy Markdown
Member

@seokho-son seokho-son left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!! I've tested it as well and it works. :)
Thanks @leehyeoklee for the contribution.

@seokho-son
Copy link
Copy Markdown
Member

/approve

@github-actions github-actions bot added the approved This PR is approved and will be merged soon. label Jan 11, 2026
@cb-github-robot cb-github-robot merged commit fc80617 into cloud-barista:main Jan 11, 2026
4 checks passed
@seokho-son seokho-son changed the title Remove curl dependency from healthcheck using bash /dev/tcp Resolve container status unhealthy in docker compose ps Jan 11, 2026
@seokho-son
Copy link
Copy Markdown
Member

@all-contributors please add @leehyeoklee for User Testing

@allcontributors
Copy link
Copy Markdown
Contributor

@seokho-son

I've put up a pull request to add @leehyeoklee! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved This PR is approved and will be merged soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants