- 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:| Command | Description |
|---|---|
docker container ls | Show running containers |
docker container ls -a | Include stopped containers |
docker container ls --filter | Filter by status, name, label, etc. |
2. Inspect Container Details
To view in-depth information—configuration, network settings, volumes—use:| JSON Field | Description |
|---|---|
Id | Unique container identifier |
Created | Timestamp when the container was instantiated |
Path | Entrypoint command executed in the container |
Args | Arguments passed to the entrypoint |
State | Current 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: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:stress process (host PID 17001) running inside webapp.
5. Fetch and Stream Container Logs
To retrieve application logs: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:docker system events.
Summary of Inspection Commands
| Command | Purpose |
|---|---|
docker container ls | List active containers |
docker container inspect <id> | Show detailed JSON metadata |
docker container stats | Stream 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 60m | Stream Docker engine events from last hour |