FROM centos:6.7
RUN ls -al
WORKDIR /
CMD "echo hi"
this is simple Dockerfile
I will create an image with this dockerfile and i'm not use shell cmd
i'm using golang "exec" package and here is code
func execCommand(buildCmd string) {
cmdArgs := strings.Fields(buildCmd)
cmd := exec.Command(cmdArgs[0], cmdArgs[1:len(cmdArgs)]...)
cmdReader, _ := cmd.StdoutPipe()
cmdReaderErr, _ := cmd.StderrPipe()
scanner := bufio.NewScanner(cmdReader)
scannerErr := bufio.NewScanner(cmdReaderErr)
cmd.Start()
go func() {
for scanner.Scan() {
fmt.Println("docker build out | ", scanner.Text())
}
if scannerErr.Scan() {
fmt.Print("docker build out err | ", scannerErr.Text())
}
fmt.Println("end end end end ")
}()
}
this code is work well but here's the problem
docker build out | Sending build context to Docker daemon 30.36MB
docker build out | Step 1/4 : FROM centos:6.7
docker build out | 6.7: Pulling from library/centos
docker build out | cbddbc0189a0: Pulling fs layer
4 line Pulling fs layer has can't change download progress bar
and suddenly showing next line
docker build out | Sending build context to Docker daemon 30.36MB
docker build out | Step 1/4 : FROM centos:6.7
docker build out | 6.7: Pulling from library/centos
docker build out | cbddbc0189a0: Pulling fs layer
docker build out | cbddbc0189a0: Verifying Checksum
docker build out | cbddbc0189a0: Download complete
docker build out | cbddbc0189a0: Pull complete
docker build out | Digest: sha256:4c952fc7d30ed134109c769387313ab864711d1bd8b4660017f9d27243622df1
docker build out | Status: Downloaded newer image for centos:6.7
this is shell command docker build log
docker build -t test:v1 .
Sending build context to Docker daemon 30.36MB
Step 1/4 : FROM centos:6.7
6.7: Pulling from library/centos
cbddbc0189a0: Downloading [===============> ] 20.92MB/67.81MB
golang stdout dosen't show Downloading [===============> ] 20.92MB/67.81MB
how can i show this stdout?