Skip to content

Instantly share code, notes, and snippets.

@Om4ar
Forked from Jimmy-Xu/pprof-in-docker-daemon.md
Created January 6, 2021 03:09
Show Gist options
  • Save Om4ar/c25e32ace7cf448024b894f7c1766380 to your computer and use it in GitHub Desktop.
Save Om4ar/c25e32ace7cf448024b894f7c1766380 to your computer and use it in GitHub Desktop.
How to run go pprof on Docker daemon

#use pprof debug docker daemon

##Start docker daemon in debug mode(add -D)

$ /usr/bin/docker daemon -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

##Run socat to make docker sock available via tcp port (note the IP to listen at)

$ socat -d -d TCP-LISTEN:8080,fork,bind=192.168.1.137 UNIX:/var/run/docker.sock

##Run pprof on your client:

$ go tool pprof http://192.168.1.137:8080/debug/pprof/profile
Fetching profile from http://192.168.1.137:8080/debug/pprof/profile
Please wait... (30s)
Saved profile in /home/xjimmy/pprof/pprof.192.168.1.137:8080.samples.cpu.001.pb.gz
Entering interactive mode (type "help" for commands)
(pprof) web     
(pprof) web ploop
(pprof) 

##debug url entrypoint

show global vars

$ curl -s http://192.168.1.137:8080/debug/vars 
  {
    "cmdline": [
      "/usr/bin/docker",
      "daemon",
      "-D",
      "-H",
      "tcp://0.0.0.0:2375",
      "-H",
      "unix:///var/run/docker.sock",
      "-api-enable-cors",
      "--storage-driver=aufs",
      "--insecure-registry",
      "registry.hyper.sh:5000",
      "--insecure-registry",
      "192.168.1.137:5000"
    ],
    "memstats": {
      "Alloc": 7140904,
      "TotalAlloc": 20379824,
      "Sys": 14559480,
      "Lookups": 3090,
      "Mallocs": 313164,
      "Frees": 199260,
      "HeapAlloc": 7140904,
      "HeapSys": 11124736,
      "HeapIdle": 1720320,
      "HeapInuse": 9404416,
      "HeapReleased": 1687552,
      "HeapObjects": 113904,
  ...

get command line

$ curl -s http://192.168.1.137:8080/debug/pprof/cmdline
  /usr/bin/dockerdaemon-D-Htcp://0.0.0.0:2375-Hunix:///var/run/docker.sock-api-enable-cors--storage-driver=aufs--insecure-registryregistry.hyper.sh:5000--insecure-registry192.168.1.137:5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment