@@ -509,6 +509,20 @@ func (t *dockerTransport) ClassifyError(processState *os.ProcessState, errorOutp
509509 return false , false , fmt .Errorf ("unable to probe container: %w" , err )
510510 }
511511
512+ // Check if the error code indicates that an agent installation attempt is
513+ // warranted. In Docker v28.0.0 and later, the exit codes for "invalid
514+ // command" and "command not found" are properly delineated (into 126 and
515+ // 127, respectively). Prior to that, they were both returned as 126. The
516+ // remainder of this comment applies to pre-v28.0.0 Docker versions and is
517+ // retained for posterity. It makes suggestions about how we might use these
518+ // delineated values to better detect Windows containers, which might be an
519+ // optimization worth pursuing at some point, but it would involve probing
520+ // the Docker engine version and adjusting behavior accordingly. Also, this
521+ // new delineated behavior might not apply on Windows, so we'd need to check
522+ // that first.
523+ //
524+ // For Docker pre-v28.0.0:
525+ //
512526 // Docker alises cases of both "invalid command" (POSIX shell error 126) and
513527 // "command not found" (POSIX shell error 127) to an exit code of 126. It
514528 // even aliases the Windows container equivalents of these errors to 126.
@@ -533,7 +547,8 @@ func (t *dockerTransport) ClassifyError(processState *os.ProcessState, errorOutp
533547 // Anyway, the exit code we need to look out for with both POSIX and Windows
534548 // containers is 126, and since we know the remote platform already, we can
535549 // return that information without needing to resort to the error string.
536- if ! process .IsPOSIXShellInvalidCommand (processState ) {
550+ if ! (process .IsPOSIXShellInvalidCommand (processState ) ||
551+ process .IsPOSIXShellCommandNotFound (processState )) {
537552 return false , false , errors .New ("unknown process exit error" )
538553 }
539554
0 commit comments