Inspecting Active Container Processes with `docker top`
Learn how to use docker top to inspect running processes, pass custom ps flags, analyze host vs container PID namespace mappings, and conduct security audits.
Published on • November 17, 2026
AI Assistant

When managing production container environments, system administrators frequently need to know what processes are executing inside a container. While executing interactive commands like docker exec -it <container> ps aux works, it requires a shell utility inside the container image and spawns a secondary process.
Docker provides a native command for process inspection: docker top. This command queries the host kernel directly to display running processes inside a container’s PID namespace without installing utilities or modifying container execution state.
Basic Usage of docker top
To inspect active processes for a running container, execute docker top followed by the container name or ID:
docker top <container_name_or_id>
Example output:
UID PID PPID C STIME TTY TIME CMD
root 24892 24870 0 10:30 ? 00:00:00 nginx: master process nginx -g daemon off;
101 24930 24892 0 10:30 ? 00:00:00 nginx: worker process
101 24931 24892 0 10:30 ? 00:00:00 nginx: worker process
PID Namespace Mapping: Host vs. Container
Understanding how processes are represented requires knowledge of Linux PID Namespaces.
When a container runs:
- Inside the container namespace, the primary process receives PID 1.
- On the Linux host system, that same process receives a unique Host PID (e.g., PID 24892).
Host Linux Operating System
├── PID 1240 (dockerd)
├── PID 24870 (containerd-shim)
└── PID 24892 (nginx master process) ◄── Same physical process ──► Container PID 1 (nginx master)
└── Container PID 12 (worker)
Notice that docker top outputs the Host PIDs by default. This design makes docker top invaluable for host-level troubleshooting: if a host monitoring tool (such as htop or top) alerts you that Host PID 24892 is consuming excessive CPU, docker top allows you to immediately correlate that Host PID back to a specific container and command.
Passing Custom ps Options
The docker top command allows system administrators to append standard Linux ps flags to format or filter process output.
docker top <container_id> [ps_options]
📌 Note: Available
psoptions depend on the host operating system’spsbinary, as Docker forwards arguments to the host host’spscommand.
1. Detailed Full Listing (aux)
Display user, memory usage, CPU percentage, start time, and full command arguments:
docker top web-api aux
Output:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 24892 0.0 0.1 11452 3420 ? Ss 10:30 0:00 nginx: master process nginx -g daemon off;
101 24930 0.0 0.2 11890 5120 ? S 10:30 0:00 nginx: worker process
101 24931 0.0 0.2 11890 5120 ? S 10:30 0:00 nginx: worker process
2. Custom Column Specification (-eo)
Extract specific fields such as Process ID, User, Memory, and Command String:
docker top web-api -eo pid,user,vsz,rss,comm
Output:
PID USER VSZ RSS COMMAND
24892 root 11452 3420 nginx
24930 101 11890 5120 nginx
24931 101 11890 5120 nginx
docker top vs. docker exec ps
| Feature | docker top | docker exec <container> ps |
|---|---|---|
| Execution Path | Executed directly on host host. | Executed inside container namespace. |
| Container Binaries Required | None (works on minimal images like scratch). | Requires /bin/ps binary inside image. |
| PID Namespace View | Displays Host PIDs and host users. | Displays Container PIDs (PID 1, 2, etc.). |
| Performance Overhead | Zero overhead; reads /proc on host. | Spawns a new process inside container. |
| Security Impact | Non-invasive read-only inspection. | Modifies container execution state. |
Practical Security Auditing and Incident Response
docker top is a key tool during security incident response and container auditing.
1. Auditing Minimal/Distroless Containers
Modern security practices recommend building container images using minimal distroless or scratch bases. These images do not contain shell binaries (/bin/sh or /bin/bash) or diagnostics (ps, top).
Because docker top runs on the host, you can inspect processes running inside minimal or distroless containers without installing extra tools:
# Inspect process list inside a distroless Go container
docker top distroless-app
2. Detecting Unauthorized Processes (Cryptominers / Shells)
If a containerized web application suffers an RCE (Remote Code Execution) exploit, an attacker may launch background mining processes or reverse shells (xmrig, nc, bash -i).
docker top reveals secondary child processes running inside the container:
docker top web-api aux
If the container was designed to execute only node server.js, but docker top displays:
USER PID %CPU %MEM COMMAND
node 24892 0.5 1.2 node server.js
node 29102 98.2 5.4 /tmp/xmrig --url pool.example.com
You have immediate confirmation of a security breach without having to modify container state.
Takeaway:
The docker top command enables non-invasive process inspection for running containers directly from the host. By mapping container processes to host PIDs and supporting custom ps options, docker top provides critical visibility for performance monitoring, host process correlation, and security auditing—even on minimal or distroless container images lacking internal shell tools.