# docker logs Command Reference

> Reference for docker logs in CI: fetch container stdout and stderr with --tail, --since, --timestamps, and -f to debug failed service containers in pipelines.

Source: https://latchkey.dev/learn/command-reference/docker-logs-command-reference  
Updated: 2026-06-26

Fetch the logs of a container.

docker logs prints the stdout and stderr a container has produced. In CI it is the first stop when a service container fails to start or a test cannot connect; dumping logs in a failure step turns an opaque error into a readable one.

## Common flags

- `-f, --follow` - stream new log output (avoid in CI unless backgrounded)
- `--tail` - show the last N lines, e.g. --tail 100
- `--since` - show logs after a timestamp or relative time, e.g. 5m
- `-t, --timestamps` - prefix each line with a timestamp
- `--until` - show logs before a timestamp

## Example

```shell
docker logs --tail 200 --timestamps app-db
docker logs --since 2m app-web
```

## In CI

Add a failure step that runs docker logs --tail 200 for each service container so a flaky integration test leaves actionable output. Do not use -f in a normal step (it blocks forever); if you must follow, background it or bound it with timeout.

## FAQ

### docker logs Command Reference?

docker logs prints the stdout and stderr a container has produced. In CI it is the first stop when a service container fails to start or a test cannot connect; dumping logs in a failure step turns an opaque error into a readable one.

### In CI?

Add a failure step that runs docker logs --tail 200 for each service container so a flaky integration test leaves actionable output. Do not use -f in a normal step (it blocks forever); if you must follow, background it or bound it with timeout.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
