Tail logs

2 snippets in Docker

DKDocker

View Container Logs

DK · Containers
syntax
docker logs [options] <container>
example
docker logs web-api
docker logs -f --tail 50 web-api
docker logs --since 10m web-api
output
Server listening on port 3000
GET /api/users 200 12ms

Note Use -f to follow in real time (like tail -f). Combine --tail and --since to avoid dumping thousands of lines. Logs persist until the container is removed.

Follow Logs in Real Time

DK · Debugging
syntax
docker logs -f [--tail <n>] <container>
example
docker logs -f --tail 100 web-api
docker logs -f --since 5m web-api
output
Server started on port 3000
GET /api/health 200 2ms
POST /api/users 201 45ms

Note Combine --tail to avoid the initial flood and --since to only see recent entries. Pressing Ctrl+C stops following but does not affect the container.