Skip to content
Closed
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions pages/common/docker-compose-logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# docker compose logs

> View output from containers in a Docker Compose application.
> More information: <https://docs.docker.com/reference/cli/docker/compose/logs/>.

- View logs for all services:

`docker compose logs`

- View logs for a specific service:

`docker compose logs {{service_name}}`

- View logs and follow new output (like tail -f):

`docker compose logs {{[-f|--follow]}}`

- View logs with timestamps:

`docker compose logs {{[-t|--timestamps]}}`

- View only the last N lines of logs for each container:

`docker compose logs {{[-n|--tail]}} {{100}}`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`docker compose logs {{[-n|--tail]}} {{100}}`
`docker compose logs {{[-n|--tail]}} {{line_count}}`

Copy link
Member

@Managor Managor Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All are valid. Depends on what you want to do.
Do you want to describe the purpose of said number with words? Use {{line_number}}
Want to demonstrate with an example what the argument should look like? Use {{2474627}}
Want to keep it super simple with a one-letter variable? Use {{n}}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially used {{100}} as an example value to show a realistic usage(showing the last 100 lines), which is a common option in Docker and Unix commands (--tail 100, similar to tail -n 100).

Since I agree with you to use a generic placeholder it's better for new users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of now for new users I think we should use line_count only

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want a generic placeholder like {{N}}.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use lowercase {{n}} for consistency.


- View logs from a specific time onwards:

`docker compose logs --since {{timestamp}}`

- View logs until a specific time:

`docker compose logs --until {{timestamp}}`

- View logs for multiple specific services:

`docker compose logs {{service1 service2 ...}}`