When using BuildKit with Docker, how do I see the output of RUN commands?
Asked Answered
C

3

126

When building Docker images with DOCKER_BUILDKIT=1, there is a very cool progress indicator but no command output. How do I see the command output to debug my build?

Classless answered 19/4, 2019 at 3:51 Comment(0)
M
183

Have you tried --progress=plain?

Example:

  • Dockerfile

    FROM alpine
    RUN ps aux
    
  • build command:

    DOCKER_BUILDKIT=1 docker build --progress=plain -t test_buildkit .
    

Relative output:

#5 [2/2] RUN ps aux
#5       digest: sha256:e2e4ae1e7db9bc398cbcb5b0e93b137795913d2b626babb0f148a60017379d86
#5         name: "[2/2] RUN ps aux"
#5      started: 2019-04-19 09:02:58.922035874 +0000 UTC
#5 0.693 PID   USER     TIME  COMMAND
#5 0.693     1 root      0:00 ps aux
#5    completed: 2019-04-19 09:02:59.721490002 +0000 UTC
#5     duration: 799.454128ms

πŸ‘‰ Also, check the very useful answer by @Cocowalla below about BUILDKIT_PROGRESS=plain

Monongahela answered 19/4, 2019 at 9:7 Comment(4)
Also, make sure that the layer where print output is expected is not cached (--no-cache ). Otherwise, it won't print the expected output. – Exorcism
Do you know how to do this but only for one specific RUN line? – Hypersthene
Hi @0xfede7c8, no I don't and I also couldn't find anything after a bit of search... – Monongahela
nope, doesn't work anymore. #18 [14/16] RUN ls /app/node_modules #18 DONE 175.0s – Forage
C
137

As well as using --progress=plain on the command line, you can also set an environment variable:

BUILDKIT_PROGRESS=plain

I find this particularly useful for CI builds, where I always want the full log.

Clinic answered 21/12, 2019 at 23:3 Comment(2)
Thank you! This is very useful when using docker-compose as you can't pass there --progress option. – Boaz
We can also use BUILDKIT_PROGRESS=plain to ensure the docker build output is not colored and can be seen on a black foreground terminal. – Barleycorn
J
4

With PR #2954 you can specify:

export NO_COLOR=1

There have also been changes in recent versions to make the defaults more readable.

You can pick your own color scheme with the BUILDKIT_COLORS variable, e.g.:

export BUILDKIT_COLORS=run=123,20,245:error=yellow:cancel=blue:warning=white

(Note, if the above doesn't work for you, then that PR likely hasn't made it into your Desktop install yet.)

Other options to solve this include switching to plain output with either the --progress=plain option or export BUILDKIT_PROGRESS=plain. Or you could disable buildkit with export DOCKER_BUILDKIT=0.

Journalese answered 2/8, 2022 at 13:2 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.