Skip to content

Commit

Permalink
Capture stderr from Docker container (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
x4204 authored Jul 14, 2024
1 parent 62a0dc9 commit cad2555
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions internal/dag/executor/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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
}

Expand Down

0 comments on commit cad2555

Please sign in to comment.