From dd7af840e6d94f59bfc9eee5543c66876569c626 Mon Sep 17 00:00:00 2001 From: Roman Popa Date: Sun, 14 Jul 2024 15:44:41 +0200 Subject: [PATCH 1/2] Capture stderr from Docker container --- internal/dag/executor/docker.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/internal/dag/executor/docker.go b/internal/dag/executor/docker.go index 4b61e76e9..c4a233589 100644 --- a/internal/dag/executor/docker.go +++ b/internal/dag/executor/docker.go @@ -95,6 +95,22 @@ func (e *docker) Run() error { } }() + out, err := cli.ContainerLogs( + ctx, resp.ID, types.ContainerLogsOptions{ + ShowStdout: true, + ShowStderr: true, + Follow: true, + }, + ) + if err != nil { + return err + } + + go func() { + _, err = stdcopy.StdCopy(e.stdout, e.stdout, out) + util.LogErr("docker executor: stdcopy", err) + }() + statusCh, errCh := cli.ContainerWait( ctx, resp.ID, container.WaitConditionNotRunning, ) @@ -109,16 +125,6 @@ func (e *docker) Run() error { } } - out, err := cli.ContainerLogs( - ctx, resp.ID, types.ContainerLogsOptions{ShowStdout: true}, - ) - if err != nil { - return err - } - - _, err = stdcopy.StdCopy(e.stdout, e.stdout, out) - util.LogErr("docker executor: stdcopy", err) - return nil } From 990e01ef4fea6a341bf881cef9d6d8b0470485fb Mon Sep 17 00:00:00 2001 From: Roman Popa Date: Sun, 14 Jul 2024 15:56:21 +0200 Subject: [PATCH 2/2] Make linter happy --- internal/dag/executor/docker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/dag/executor/docker.go b/internal/dag/executor/docker.go index c4a233589..69bfc3d98 100644 --- a/internal/dag/executor/docker.go +++ b/internal/dag/executor/docker.go @@ -99,7 +99,7 @@ func (e *docker) Run() error { ctx, resp.ID, types.ContainerLogsOptions{ ShowStdout: true, ShowStderr: true, - Follow: true, + Follow: true, }, ) if err != nil {