From 05cfe833da492fc02844352b6affb7c465535d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=A5=E6=B5=A9?= Date: Tue, 23 Sep 2025 11:09:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(docker-exec-via-sock):=20=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E5=B1=95=E7=A4=BA=E5=92=8C?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=89=A7=E8=A1=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-exec-via-sock.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docker-exec-via-sock.sh b/docker-exec-via-sock.sh index 833d124..ad631f4 100644 --- a/docker-exec-via-sock.sh +++ b/docker-exec-via-sock.sh @@ -72,8 +72,8 @@ docker_exec_create() { docker_exec_create_id=$(printf '%s' "$DOCKER_LAST_RESPONSE" | jq -r '.Id // empty') if [ -z "$docker_exec_create_id" ]; then - log "failed to create $docker_exec_create_desc exec for $CONTAINER_NAME" - log "docker response: $DOCKER_LAST_RESPONSE" + error_message=$(printf '%s' "$DOCKER_LAST_RESPONSE" | jq -r '.message // "unknown error"') + log "failed to create $docker_exec_create_desc exec for $CONTAINER_NAME: $error_message" return 1 fi @@ -189,13 +189,13 @@ fi log "starting exec $exec_id" -if ! start_output=$(docker_exec_start "$exec_id" "exec"); then - exit 1 -fi +start_output=$(docker_exec_start "$exec_id" "exec") || true if ! exit_code=$(docker_exec_exit_code "$exec_id"); then - log "could not determine exec exit code" - log "docker inspect response: $DOCKER_LAST_RESPONSE" + error_message=$(printf '%s' "$DOCKER_LAST_RESPONSE" | jq -r '.message // "unknown error"') + log "could not determine exec exit code: $error_message" + log "this often happens if the command inside the container fails immediately (e.g. command not found)." + log "initial command output from container: $start_output" exit 1 fi