Use docker’s stdcopy to ensure we don’t emit garbage bytes to stdout

This commit is contained in:
Aidan Steele
2019-04-09 20:45:58 +10:00
parent f2cb9e391e
commit 1d64fef1a1
2 changed files with 60 additions and 6 deletions

View File

@@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/docker/docker/pkg/stdcopy"
"io"
"os"
@@ -31,12 +32,10 @@ type dockerMessage struct {
}
func (i *DockerExecutorInput) logDockerOutput(dockerResponse io.Reader) {
scanner := bufio.NewScanner(dockerResponse)
if i.Logger == nil {
return
}
for scanner.Scan() {
i.Logger.Infof(scanner.Text())
w := i.Logger.Writer()
_, err := stdcopy.StdCopy(w, w, dockerResponse)
if err != nil {
i.Logger.Error(err)
}
}