# Docker Logs Grep Guide

Filter docker compose logs with grep-style context, invert and dedupe modes.

- Tool: https://ilham.dev/tools/docker-logs-grep/
- Guide URL: https://ilham.dev/guides/docker-logs-grep/
- Tool guides index: https://ilham.dev/guides/tools/
- Broader guide: Filtering Docker Logs Effectively (https://ilham.dev/guides/docker-logs/)

## What it does

Paste the output of docker compose logs and filter it like grep. Match with context (the equivalent of grep -C, with separate before and after counts), show matching lines only, invert the match, count matches, or list unique matching lines. Context groups are separated by "--" and line numbers use ":" for a match and "-" for context, so the output looks like grep -n -C. Everything runs in the page, so log contents never leave the browser.

## Use the tool

Open https://ilham.dev/tools/docker-logs-grep/, add the input the tool asks for, run it, and check the output before using it elsewhere.

## Input and output

- Input: text.
- Output: text.
- Category: Workflow.

## Privacy and processing
Processing happens locally in your browser. This tool does not upload the input to ilham.dev.

## Questions

### How do I get 10 lines before and 5 lines after a match?

Leave the grep type on Match with context, set Lines before to 10 and Lines after to 5. That is the same as grep -B 10 -A 5, and grep -C would use the larger of the two.

### What is the difference between Regex and plain search?

With Regex checked, the pattern is a JavaScript regular expression, so error|timeout matches either word and ^api matches the start of a line. With Regex unchecked every character is literal, so a dot matches only a dot.

### Can I dedupe a noisy log?

Yes. Use the Unique matching lines type, which behaves like grep ... | sort | uniq -c and prefixes each distinct line with how many times it appeared. A pattern of . matches every line, so it can dedupe the whole file.