cli icon indicating copy to clipboard operation
cli copied to clipboard

imgproxy container collects zombie processes when its healthcheck times out

Open sudhi76 opened this issue 1 week ago • 0 comments

Affected area

Docker

Supabase CLI version

develop after #7784

Operating system

macOS 15.6 (Docker via Colima)

Installation method

Other (reproduced with the CLI's healthcheck form directly, see below)

Command

supabase start

Actual output

Same cause as #7776, in a service #7784 didn't cover. imgproxy.service.ts uses ["CMD", "imgproxy", "health"], but buildHealthCmdArg joins it into one --health-cmd string, so Docker runs it with /bin/sh -c. In the imgproxy image sh is dash and stays as the parent. On timeout Docker kills sh, and the orphan goes to PID 1 (imgproxy), which doesn't reap it.

Expected behavior

No zombie processes when a check times out.

Steps to reproduce

The check is pointed at an unreachable address to force the timeout:

IMG=darthsim/imgproxy:v3.26.0
CHECK="env IMGPROXY_BIND=10.255.255.1:8080 imgproxy health"
docker run -d --name im-plain --health-interval=3s --health-timeout=1s --health-cmd "$CHECK" $IMG
docker run -d --name im-exec  --health-interval=3s --health-timeout=1s --health-cmd "exec $CHECK" $IMG
sleep 45
for c in im-plain im-exec; do
  docker exec $c sh -c 'grep -l "^State:.*Z" /proc/[0-9]*/status | wc -l; ls -d /proc/[0-9]* | wc -l'
done
# im-plain: 4 zombies, 14 processes
# im-exec:  0 zombies,  4 processes

Additional context

With the normal check, both forms report healthy and leave 0 zombies. I haven't seen this happen in a real supabase start; it needs a check slower than 2s.

Other services, with the images I had locally:

  • studio, pg-meta: fixed in #7784
  • storage, gotrue, vector, kong: no orphan, busybox sh execs the command itself
  • realtime, supavisor: PID 1 is tini, which reaps orphans (from the image config)
  • logflare: PID 1 is sh waiting on a child; 0 zombies in an equivalent setup

Suggested fix: have buildHealthCmdArg emit exec <args> for ["CMD", ...] tests. That covers every exec-form check.

I'd like to work on this; I'll open a PR once it's open-for-contribution.

sudhi76 avatar Nov 25 '26 11:11 sudhi76