Skip to content

Commit c449c1a

Browse files
committed
plugins/hooks: run hooks when exit code != 0
Particularly for cases such as `docker exec -it`, it's relevant that the CLI still executes hooks even if the exec exited with a non-zero exit code, since this is can be part of a normal `docker exec` invocation depending on how the user exits. In the future, this might also be interesting to allow plugins to run hooks after an error so they can offer error-state recovery suggestions, although this would require additional work to give the plugin more information about the failed execution. Signed-off-by: Laura Brehm <[email protected]>
1 parent c0cc22d commit c449c1a

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

cmd/docker/docker.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,14 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
353353
// which remain.
354354
cmd.SetArgs(args)
355355
err = cmd.Execute()
356-
if err != nil {
357-
return err
358-
}
359356

360357
// If the command is being executed in an interactive terminal,
361358
// run the plugin hooks (but don't throw an error if something misbehaves)
362359
if dockerCli.HooksEnabled() && dockerCli.Out().IsTerminal() && subCommand != nil {
363360
_ = pluginmanager.RunPluginHooks(dockerCli, cmd, subCommand, "", args)
364361
}
365362

366-
return nil
363+
return err
367364
}
368365

369366
type versionDetails interface {

0 commit comments

Comments
 (0)