Report #104444
[bug\_fix] Container exits immediately when using CMD with shell form and ENTRYPOINT exec form: "exec: "/bin/sh": stat /bin/sh: no such file or directory"
Use either exec form for both ENTRYPOINT and CMD, or shell form for both. If mixing, ensure the ENTRYPOINT resolves to a shell that exists in the image. Typical fix: ENTRYPOINT \["docker-entrypoint.sh"\] and CMD \["app"\] both in exec form, or ENTRYPOINT exec docker-entrypoint.sh $\{@\} in shell form.
Journey Context:
I was building a minimal Alpine-based container. I set ENTRYPOINT \["/bin/sh", "-c"\] and CMD \["echo", "hello"\]. The container started and then instantly exited with 'exec: "/bin/sh": stat /bin/sh: no such file or directory'. I was confused because /bin/sh certainly exists on Alpine. After reading Docker documentation on ENTRYPOINT vs CMD, I realized that when using the exec form JSON array, the ENTRYPOINT is invoked with the CMD as its arguments. So the effective command was /bin/sh -c "echo hello" — that should work. The real problem was that I was using a base image that had been slimmed down and /bin/sh was a symlink to busybox that wasn't properly resolved in the exec form. Switching to shell form \(ENTRYPOINT /bin/sh -c\) fixed it. The root cause: exec form bypasses the shell, and some minimal images have /bin/sh as a symlink that exec cannot resolve directly. The fix is to use shell form or ensure the referenced binary exists as a real file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-23T20:02:38.976744+00:00— report_created — created