🐛 Fix entrypoint arg passthrough — commands no longer hang 🐛

Root cause: entrypoint.sh unconditionally called `__no_exit` (an
`exec bash -c` monitoring loop) even when the user passed a command
to `docker run`, replacing the shell before the command could execute.
Secondary bug in `__exec_command`: used `bash --login -c "$cmdExec"`
which only captured the first word of the command and spawned a slow
login shell on every invocation.
- rootfs/usr/local/bin/entrypoint.sh: only call `__no_exit` when no
user command was given (`$# -eq 0`); otherwise fall through to the
case dispatch so `docker run ... go version` works correctly
- rootfs/usr/local/etc/docker/functions/entrypoint.sh: rewrite
`__exec_command` to use `exec "$@"` directly instead of wrapping
in `bash --login -c "$cmdExec"`; both files kept in sync

rootfs/usr/local/bin/entrypoint.sh
rootfs/usr/local/etc/docker/functions/entrypoint.sh
This commit is contained in:
2026-05-31 00:34:21 -04:00
parent 65346b72af
commit 2568aaa0f2
2 changed files with 12 additions and 14 deletions
+3 -1
View File
@@ -506,10 +506,12 @@ if [ "$START_SERVICES" = "yes" ] || [ -z "$1" ]; then
echo "$$" >"$ENTRYPOINT_PID_FILE" echo "$$" >"$ENTRYPOINT_PID_FILE"
__start_init_scripts "/usr/local/etc/docker/init.d" __start_init_scripts "/usr/local/etc/docker/init.d"
CONTAINER_INIT="${CONTAINER_INIT:-no}" CONTAINER_INIT="${CONTAINER_INIT:-no}"
# Services started successfully - enter monitoring mode # Only block in monitoring mode when no user command was given
if [ $# -eq 0 ]; then
__no_exit __no_exit
exit $? exit $?
fi fi
fi
START_SERVICES="no" START_SERVICES="no"
fi fi
export START_SERVICES CONTAINER_INIT ENTRYPOINT_PID_FILE export START_SERVICES CONTAINER_INIT ENTRYPOINT_PID_FILE
@@ -885,23 +885,19 @@ __create_env_file() {
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - -
__exec_command() { __exec_command() {
local arg=("$@")
local exitCode=0 local exitCode=0
local cmdExec="${arg:-}" local bin="${1:-bash}"
local pre_exec="--login -c" local prog
local shell bin prog
shell=$(type -P bash || type -P dash || type -P ash || type -P sh) 2>/dev/null
bin="${arg[0]:-bash}"
prog="$(type -P "$bin" 2>/dev/null || echo "$bin")" prog="$(type -P "$bin" 2>/dev/null || echo "$bin")"
if type -t "$bin" &>/dev/null; then if [ -x "$prog" ]; then
echo "${exec_message:-Executing command: $cmdExec}" echo "${exec_message:-Executing: $*}"
"$shell" $pre_exec "$cmdExec" exec "$@"
exitCode=$? exitCode=$?
elif [ -f "$prog" ]; then elif [ -f "$prog" ]; then
echo "$prog is not executable" echo "Error: $prog is not executable" >&2
exitCode=98 exitCode=98
else else
echo "$prog does not exist" echo "Error: command not found: $bin" >&2
exitCode=99 exitCode=99
fi fi
return $exitCode return $exitCode