1

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?

Dastan Alybaev
  • 309
  • 4
  • 12

1 Answers1

1

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>
VietHTran
  • 2,233
  • 2
  • 9
  • 16