Reputation: 3608
I am using docker buildkit to build an image, which produces a lot of output from the command in the docker file. Something is going wrong in the build, and there is a lot of text to scroll through on the terminal. I would like to capture it to a file, where I can search it with my text editor. However, it appears that docker writes the output directly to the terminal, not going through stdout or stderr.
That is:
$ docker build . <various args> 2>&1 > build.log
still produces output to the terminal, and build.log is empty.
I found a page suggesting --progress=plain
, but that only appears to affect what is output, not where it is output.
$ docker --version
Docker version 20.10.12, build e91ed57
Upvotes: 2
Views: 2607
Reputation: 991
Ran into this and found an answer over in the Docker forums. In short, the output is not written to the standard output stream (stdout) but to the standard error stream (stderr). This worked for me:
# write everything to build.log
docker build --no-cache --progress=plain . &> build.log
Other things to try are:
# only write error output to build.log
docker build --no-cache --progress=plain . 2> build.log
# stream output to console and write it to build.log
docker build --no-cache --progress=plain . 2>&1 | tee build.log
Upvotes: 2
Reputation: 2026
This just worked for me :
docker build -t nice-image . > bla.log
using Docker version 20.10.7, build v20.10.7
and zsh shell.
Upvotes: 1