Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running atop in a docker stack

atop is a tool I install on all my servers to go and check out what was happening on a machine when debugging site events. Is there a nice "docker" way to run atop in your fleet, or should I just get atop running in the os below docker?

Related to this is all the other tools I love having to debug issues: strace, iotop, htop, tcpdump, perf, etc. What are people doing in production to cover this niche.

like image 394
Keegan Carruthers-Smith Avatar asked Mar 16 '23 02:03

Keegan Carruthers-Smith


1 Answers

You can achieve this by running the container with --pid=host (See the Docker Run Reference;

In certain cases you want your container to share the host’s process namespace, basically allowing processes within the container to see all of the processes on the system. For example, you could build a container with debugging tools like strace or gdb, but want to use these tools when debugging processes within the container.

An example of a Dockerfile to run htop created by one of the Docker Maintainers can be found here; https://github.com/jfrazelle/dockerfiles/blob/master/htop/Dockerfile (and many more great examples in that repository). An automated build of that image can be found on Docker Hub here; https://hub.docker.com/r/jess/htop/

Run it like this;

docker run --rm -it --pid host jess/htop
like image 179
thaJeztah Avatar answered Mar 23 '23 20:03

thaJeztah