Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No progress bar in docker logs #651

Open
funlennysub opened this issue Jul 21, 2024 · 9 comments
Open

No progress bar in docker logs #651

funlennysub opened this issue Jul 21, 2024 · 9 comments

Comments

@funlennysub
Copy link

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:

  1. cargo run -r - progress bar will be displayed
  2. docker build --tag 'whatever' .
  3. docker run 'whatever' - progress bar won't be displayed
@djc
Copy link
Member

djc commented Jul 22, 2024

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.

@funlennysub
Copy link
Author

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?

@chris-laplante
Copy link
Collaborator

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.

@funlennysub
Copy link
Author

funlennysub commented Jul 24, 2024

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 unbuffer
  • CMD ["unbuffer", "-p", "/products_bin"] - app just closes immediately

@chris-laplante
Copy link
Collaborator

I'm still not quite sure what you're trying to do, but perhaps this will help: chris-laplante/fuzzy-octo-pancake@6cb2eb1.

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!

@funlennysub
Copy link
Author

funlennysub commented Jul 29, 2024

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

@chris-laplante
Copy link
Collaborator

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?

@funlennysub
Copy link
Author

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 ...

@djc
Copy link
Member

djc commented Jul 31, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants