dockerdocker-for-windowsdocker-build

How to see docker build "RUN command" stdout? (docker for windows)


In the past I could simply do something like this:

Dockerfile:

FROM ubuntu
RUN echo "test"

which would output test to my shell. I used this as a way of debugging my builds.

In the latest stable version of docker for windows the build output looks completely different and is not showing any stdout from any command.

How can I see the output of any command in the build process?

The current output looks like this for above Dockerfile example:

[+] Building 4.7s (6/6) FINISHED
 => [internal] load build definition from Dockerfile                                                                       0.0s 
 => => transferring dockerfile: 65B                                                                                        0.0s 
 => [internal] load .dockerignore                                                                                          0.0s 
 => => transferring context: 2B                                                                                            0.0s 
 => [internal] load metadata for docker.io/library/ubuntu:latest                                                           2.0s 
 => [1/2] FROM docker.io/library/ubuntu@sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c            2.3s 
 => => resolve docker.io/library/ubuntu@sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c            0.0s 
 => => sha256:f643c72bc25212974c16f3348b3a898b1ec1eb13ec1539e10a103e6e217eb2f1 3.32kB / 3.32kB                             0.0s 
 => => sha256:da7391352a9bb76b292a568c066aa4c3cbae8d494e6a3c68e3c596d34f7c75f8 28.56MB / 28.56MB                           1.2s 
 => => sha256:14428a6d4bcdba49a64127900a0691fb00a3f329aced25eb77e3b65646638f8d 847B / 847B                                 0.5s 
 => => sha256:c95a8e48bf88e9849f3e0f723d9f49fa12c5a00cfc6e60d2bc99d87555295e4c 1.20kB / 1.20kB                             0.0s 
 => => sha256:4e4bc990609ed865e07afc8427c30ffdddca5153fd4e82c20d8f0783a291e241 943B / 943B                                 0.0s 
 => => extracting sha256:da7391352a9bb76b292a568c066aa4c3cbae8d494e6a3c68e3c596d34f7c75f8                                  0.8s 
 => => extracting sha256:14428a6d4bcdba49a64127900a0691fb00a3f329aced25eb77e3b65646638f8d                                  0.0s 
 => => extracting sha256:2c2d948710f21ad82dce71743b1654b45acb5c059cf5c19da491582cef6f2601                                  0.0s 
 => [2/2] RUN echo "test"                                                                                                  0.3s 
 => exporting to image                                                                                                     0.0s 
 => => exporting layers                                                                                                    0.0s 
 => => writing image sha256:8c61a015c1cc5af925e0db03bb56a627ce3624818c456fca11379c92c2e9d864                               0.0s 

Solution

  • Reading through When using BuildKit with Docker, how do I see the output of RUN commands? the reason for the changed output format is that instead of the "classic" docker build a new feature named "buildkit" is now being used instead.

    Method 1 (taken from above questions answers)

    Use docker build --progress=plain . to see the plain output.

    To permanently set the progress to plain the ENV BUILDKIT_PROGRESS=plain can be set.

    For a quick win (non permanent) I simply added the following line to the beginning of my scripts:

    Method 2 (Not recommended)

    Disable buildkit in the settings docker engine features enter image description here