Search code examples
linuxdockerterminalless

How can I paginate docker logs commands in linux?


I am not able to paginate docker logs commands with less.

docker logs <CONTAINER> | less jumps right to the end. I have to &> to a temp file and paginate there.

Why is that? How is it possible to paginate?

I searched extensively and tried less -R, less -S and other suggestions but nothing worked.


Solution

  • some_command | less only sends stdout to the less command, and everything printed to stderr will be displayed outside of less.

    To merge stderr into stdout, you can use the syntax:

    some_command 2>&1 | less