Docker build is not sending result of RUN commands like echo to stdout in terminal [duplicate]

  build, docker, stdout

I am using Docker 3.2.2 osx and it seems that lately when I add a line like RUN ls -la in my Dockerfile I am no longer seeing the output of the command in my terminal. There seems to be a new feature that compresses the output on the fly and I don’t know if that is related.

I have tried other variants like RUN echo "hello there!" and RUN ['ls', '-la'] and so forth but no results. I have also tried using docker build --output type=local,dest=./ . and docker build --progress=plain . with no results.

FROM alpine:3.4
RUN apk update -q && apk add --no-cache bash -q
SHELL ["/bin/bash", "--login", "-c"]
RUN echo $0

docker build --no-cache .

[+] Building 3.2s (7/7) FINISHED                                                                                                                                                     => [internal] load build definition from Dockerfile.log                                                                                                                       0.0s
 => => transferring dockerfile: 40B                                                                                                                                            0.0s
 => [internal] load .dockerignore                                                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                                                0.0s
 => [internal] load metadata for docker.io/library/alpine:3.4                                                                                                                  0.4s
 => CACHED [1/3] FROM docker.io/library/alpine:[email protected]:b733d4a32c4da6a00a84df2ca32791bb03df95400243648d8c539e7b4cce329c                                                     0.0s
 => [2/3] RUN apk update -q && apk add --no-cache bash -q                                                                                                                      2.2s
 => [3/3] RUN echo $0                                                                                                                                                          0.3s
 => exporting to image                                                                                                                                                         0.2s
 => => exporting layers                                                                                                                                                        0.2s
 => => writing image sha256:df07245054bab5d0238fe7781e9a452330b3bb650ebb3a68ddb260189641aec9      

And with –progress=plain.
docker build -f Dockerfile.log --progress=plain --no-cache .

#1 [internal] load build definition from Dockerfile.log
#1 sha256:3540d72c8695d436e5b9591dd3472d670599a4143505fa8c4df8b86950e5b43a
#1 transferring dockerfile: 159B 0.0s done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 sha256:49ec0566fb6489c7524048aa3a989dbb0f18f3df3e45185ff84aeb749c647967
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/alpine:3.4
#3 sha256:dea9a758ed50ccd28b8468898e3ae2edc34c169e0bf133370135271664b19f78
#3 ...

#4 [auth] library/alpine:pull token for registry-1.docker.io
#4 sha256:425b2d79749d37304d10f2f60c84215065b9b679e033b0a74ad451a138353aab
#4 DONE 0.0s

#3 [internal] load metadata for docker.io/library/alpine:3.4
#3 sha256:dea9a758ed50ccd28b8468898e3ae2edc34c169e0bf133370135271664b19f78
#3 DONE 1.1s

#5 [1/3] FROM docker.io/library/alpine:[email protected]:b733d4a32c4da6a00a84df2ca32791bb03df95400243648d8c539e7b4cce329c
#5 sha256:374a97582db75844b0746f427fad7612843e6c0186aeb6fd00c1bce4dc2191e1
#5 DONE 0.0s

#6 [2/3] RUN apk update -q && apk add --no-cache bash -q
#6 sha256:e44463629b0e3e142b96c470e2a17f21eb363fe4a6c0e75535cf44d6f3875bd2
#6 CACHED

#7 [3/3] RUN echo $0
#7 sha256:c44c7d1bfdd33169a86cebc8b5c67050209faa7df70c7ba6b3173c45799b2995
#7 CACHED

#8 exporting to image
#8 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#8 exporting layers done
#8 writing image sha256:df07245054bab5d0238fe7781e9a452330b3bb650ebb3a68ddb260189641aec9 done
#8 DONE 0.0s

Source: Docker Questions

LEAVE A COMMENT