Skip to content

Commit cad2555

Browse files
authored
Capture stderr from Docker container (#615)
1 parent 62a0dc9 commit cad2555

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

internal/dag/executor/docker.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ func (e *docker) Run() error {
9595
}
9696
}()
9797

98+
out, err := cli.ContainerLogs(
99+
ctx, resp.ID, types.ContainerLogsOptions{
100+
ShowStdout: true,
101+
ShowStderr: true,
102+
Follow: true,
103+
},
104+
)
105+
if err != nil {
106+
return err
107+
}
108+
109+
go func() {
110+
_, err = stdcopy.StdCopy(e.stdout, e.stdout, out)
111+
util.LogErr("docker executor: stdcopy", err)
112+
}()
113+
98114
statusCh, errCh := cli.ContainerWait(
99115
ctx, resp.ID, container.WaitConditionNotRunning,
100116
)
@@ -109,16 +125,6 @@ func (e *docker) Run() error {
109125
}
110126
}
111127

112-
out, err := cli.ContainerLogs(
113-
ctx, resp.ID, types.ContainerLogsOptions{ShowStdout: true},
114-
)
115-
if err != nil {
116-
return err
117-
}
118-
119-
_, err = stdcopy.StdCopy(e.stdout, e.stdout, out)
120-
util.LogErr("docker executor: stdcopy", err)
121-
122128
return nil
123129
}
124130

0 commit comments

Comments
 (0)