Open funlennysub opened 4 months ago
I think this is more or less intentional -- indicatif checks whether the stream it is attached to is a terminal, which is probably not the case in this scenario. I think #530 covers this scenario.
Oop, sorry for not replying for a while. Could you explain a bit more why this happens when output is being written to a file, so i can search for a solution?
Oop, sorry for not replying for a while. Could you explain a bit more why this happens when output is being written to a file, so i can search for a solution?
It is intentional, as @djc mentioned. The underlying reason is that it is hard to say what should actually be written to the file. Should we write the progress bar just once (when it is 'complete'), or each time the progress ticks? What about every time the status text changes? etc etc etc.
A workaround, as mentioned in @530, is to use the 'unbuffer' tool: https://linux.die.net/man/1/unbuffer.
Im not sure how unbuffer
suppose to work in my case, i tried using these lines in my Dockerfile
:
CMD ["/products_bin", "|", "unbuffer", "-p" ]
- same as without unbufferCMD ["unbuffer", "-p", "/products_bin"]
- app just closes immediately I'm still not quite sure what you're trying to do, but perhaps this will help: https://github.com/chris-laplante/fuzzy-octo-pancake/commit/6cb2eb1226d43ff5ef60872496e888f1ac11df79.
It uses unbuffer to capture the output to a file called out.txt, then prints the contents of that file after the program is done. When I run it, I get:
chris@chris-virtual-machine:/tmp/fuzzy-octo-pancake$ docker run --rm -it 702330d842de2bc4236cc9e128c6f19a8df07908c2cfcc3131fb0e48b0be37c3
Progress bar
[00:00:05] ######################################## 500/500 Done Hello, world!
then prints the contents of that file after the program is done
Sadly i need real-time progress bar updates, or at least close to it
then prints the contents of that file after the program is done
Sadly i need real-time progress bar updates, or at least close to it
Real-time but where? Printed to a file, or output to the console?
then prints the contents of that file after the program is done
Sadly i need real-time progress bar updates, or at least close to it
Real-time but where? Printed to a file, or output to the console?
in $ docker logs ...
I'd prefer to keep this discussion in #530 so we have all of it in one place. I think it would make sense to expose some API to override the implicit terminal detection logic.
When you run an app that has a progress bar it won't be rendered when attaching to container logs, but will be present if ran via
cargo run
Sample repo: https://github.com/funlennysub/fuzzy-octo-pancake
Steps to reproduce:
cargo run -r
- progress bar will be displayeddocker build --tag 'whatever' .
docker run 'whatever'
- progress bar won't be displayed