docker-composetee

docker-compose build output to logfile


What I want to archive:

I want to store the output of the docker build process in a file and see it in the terminal online.

What I try is:

docker-compose build --progress plain myenv | tee myenv.log

What I get is:

I see the output of the build process in the terminal. The file myenv.log is generated, but is empty (size 0 Byte).

What I use:

Ubuntu 22.04 @ WSL version: 2.0.9.0 @ Windows 11

docker-compose version 1.29.2, build unknown

Any Idea?


Solution

  • Based on feedback of @BenjaminGruenbaum and How do I write standard error to a file while using "tee" with a pipe? , my working solution now looks like:

    { { docker-compose build --no-cache --progress plain  myenv  | (tee   std.log);  } 2>&1 1>&3 | tee err.log; } 3>&1 1>&2
    

    The file 'std.log' remains empty. The expected log is found in 'err.log'. It's a bit supprising that the docker-compose build output is classified as an error but that's what it is.