Docker Logs Tail
Tail logs from Docker containers to check for errors and monitor application behavior.
Instructions
When user requests to check container logs:
Discover running containers: First, list all running containers to see what's available:
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"Ask user which container(s): Present the list and ask which container(s) they want to monitor
Use appropriate command: Run
docker logswith suitable flags based on their needs
Common Commands
List running containers
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
Tail logs for a specific container
docker logs -f <container_name>
Tail logs with timestamps
docker logs -f --timestamps <container_name>
Tail last N lines
docker logs -f --tail 100 <container_name>
Check logs since specific time
docker logs -f --since 5m <container_name>
View logs from all containers (with docker compose)
docker compose logs -f
View logs from specific services
docker compose logs -f <service1> <service2>
Filter for errors
docker logs <container_name> 2>&1 | grep -i error
Usage Flow
- Run
docker psto discover available containers - Present the container list to the user
- Ask which container(s) they want to tail
- Ask if they want any filters (errors only, last N lines, since time, etc.)
- Execute the appropriate
docker logscommand