How to specify number of logs after each match of a particular string using docker log?

1.1k views Asked by At

I am new to using docker-log commands. I understood how to print logs that match specific string using grep command, here is a simple example:

docker logs {dockerId} | grep "someString"

However, my goal is to per each match print the next specific number of logs.

How can I achieve this using docker log commands?

1

There are 1 answers

0
VietHTran On BEST ANSWER

You can use the argument -A <n> in grep to print out <n> lines after the matched line

docker logs {dockerId} | grep "someString" -A <number of logs>