How to create docker goroutine, and memory heap, dumps
Article Number: 000020101
Environment
Rancher 2.x
Situation
Task
It's important to observe Docker as it operates to help drive troubleshooting an issue. Here are some commands to generate memory heap and goroutine dumps without killing the Docker process.
Pre-requisites
- Docker with an exposed socket (typically found at
/var/run/docker.sock
)
Resolution
Collecting dumps
Heap dump
Heap dumps report a sampling of memory allocations of live objects.
curl --unix-socket /var/run/docker.sock http://./debug/pprof/heap?debug=2
Goroutine dump
The goroutine dump reports stack traces of all current goroutines for the docker process.
curl --unix-socket /var/run/docker.sock http://./debug/pprof/goroutine?debug=2
The output normally is output to stdout
, where it can be redirected to a file.
Depending on how Docker is configured, and where its configured to log to, the traces could end up in the docker.log
file or with the system logs (syslog, journalctl, kern.log, messages, etc...).