Skip to main content
In this guide, you’ll learn how to explore and troubleshoot Docker containers by using built-in inspection commands. We’ll cover:
  • Listing containers
  • Retrieving detailed JSON metadata
  • Monitoring live resource usage
  • Viewing in-container processes
  • Fetching and streaming logs
  • Streaming Docker system events

1. List Running Containers

Before diving deeper, get a quick overview of containers on your host:
You can extend this with flags:
CommandDescription
docker container lsShow running containers
docker container ls -aInclude stopped containers
docker container ls --filterFilter by status, name, label, etc.

2. Inspect Container Details

To view in-depth information—configuration, network settings, volumes—use:
This outputs a JSON array. Example:
JSON FieldDescription
IdUnique container identifier
CreatedTimestamp when the container was instantiated
PathEntrypoint command executed in the container
ArgsArguments passed to the entrypoint
StateCurrent runtime status and networking information
Use -f json to pipe this output into jq or other JSON parsers for selective querying.

3. Monitor Resource Usage

Docker can stream real-time metrics—CPU, memory, network I/O, block I/O—across all running containers:
Sample output:
The stats command runs continuously. Press Ctrl+C to stop the stream.

4. List Processes Inside a Container

Identify which processes are consuming resources within a specific container:
Example:
This shows the stress process (host PID 17001) running inside webapp.

5. Fetch and Stream Container Logs

To retrieve application logs:
Follow logs in real time with:
If your logs are large, consider limiting output with options like --since or --tail to avoid overwhelming your terminal.

6. Stream Docker Events

Docker records events for containers, networks, volumes, and more. To see recent events—for example, within the last hour—run:
Sample output:
All resource lifecycle events can be retrieved using docker system events.

Summary of Inspection Commands

CommandPurpose
docker container lsList active containers
docker container inspect <id>Show detailed JSON metadata
docker container statsStream live resource usage
docker container top <name>List processes inside the container
docker container logs <id>Retrieve container logs
docker container logs -f <id>Follow logs in real time
docker system events --since 60mStream Docker engine events from last hour

Watch Video