With `docker build` is it possible to get both the build log and the ID of the generated image on stdout/stderr?

37 Views Asked by At

I know docker build ... writes all the log from the builder out to command line while docker build --quiet .. doesn't but prints the resulting image ID instead.

Both is very important IMHO, can I get both?

There is also --idfile which can supply but forces me to provide and clean up a file name.

Is there also a way to get both, the image ID and the build log just via stdout/err instead?

Docker version is 25.0.3 with BuildKit enabled

1

There are 1 best solutions below

1
shunmuga prakash On

Try pipe approach

docker build . | tee build.log | awk '/Successfully built/{print $NF}'