Commands.page Logo

Can htop Monitor Docker Container Processes on Ubuntu Host?

This article explains whether the htop process viewer can monitor tasks running within Docker containers directly from an Ubuntu host system. It covers the relationship between host and container kernels, how to identify containerized processes in the list, and the limitations you might encounter while using standard system monitoring tools.

Yes, htop can monitor processes inside a Docker container from the host. Docker containers share the same Linux kernel as the host operating system. Therefore, every process running inside a container is actually a process running on the host. When you open htop on your Ubuntu host, you are viewing the complete list of active processes, including those belonging to containers.

However, identifying which processes belong to specific containers requires attention. Docker uses PID namespaces to isolate processes. This means the Process ID (PID) inside the container is different from the PID visible on the host. htop displays the host PID. To distinguish container processes, look at the COMMAND column. Container processes often display the entrypoint or command used to start the container, such as nginx, python app.py, or specific container runtime arguments.

For better visibility, you can configure htop to show cgroup information. Adding the CGROUP column to the htop display allows you to see the container ID or name associated with each process. This makes it significantly easier to filter and identify containerized workloads among standard system processes.

While htop works, dedicated tools like docker top or ctop provide a more container-centric view. docker top <container_id> shows processes specifically for one container, while ctop offers a top-like interface specifically designed for Docker containers. Nevertheless, for a quick check of resource usage across the entire system, htop remains a valid and effective tool for monitoring Docker processes on Ubuntu.