Skip to content

Instantly share code, notes, and snippets.

@erikcw
Created February 25, 2016 17:34
Show Gist options
  • Save erikcw/c909f71199d8351fac8c to your computer and use it in GitHub Desktop.
Save erikcw/c909f71199d8351fac8c to your computer and use it in GitHub Desktop.
Attaching GDB to nginx running inside docker container.
root@b13239f0d920:/opt/openresty/nginx/conf# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 21564 2228 ? Ss Feb24 0:00 /usr/bin/lua -lluarocks.loader /usr/local/lib/luarocks/rocks/lapis/1.4.3-1/bin/lapis server production
root 20 0.0 0.0 4440 652 ? S Feb24 0:00 sh -c /opt/openresty/nginx/sbin/nginx -p "$(pwd)"/'' -c 'nginx.conf.compiled'
root 22 0.0 0.1 54944 4280 ? S Feb24 0:00 nginx: master process /opt/openresty/nginx/sbin/nginx -p /opt/openresty/nginx/conf/ -c nginx.conf.compiled
nobody 24 0.0 0.0 54944 1964 ? S Feb24 0:00 nginx: cache manager process
nobody 473 94.6 25.9 1107220 1050740 ? R 02:22 861:17 nginx: worker process is shutting down
root 478 0.1 0.0 18156 1964 ? Ss 17:30 0:00 bash
root 498 0.0 0.0 15564 1144 ? R+ 17:31 0:00 ps aux
root@b13239f0d920:/opt/openresty/nginx/conf# gdb /opt/openresty/nginx/sbin/nginx 473
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /opt/openresty/nginx/sbin/nginx...done.
Attaching to program: /opt/openresty/nginx/sbin/nginx, process 473
Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
/opt/openresty/nginx/conf/473: No such file or directory.
(gdb)
$ sudo gdb /opt/openresty/nginx/sbin/nginx 32176
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
/opt/openresty/nginx/sbin/nginx: No such file or directory.
Attaching to process 32176
/opt/openresty/nginx/sbin/nginx: No such file or directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment