How to debug applications with GDB and pstack inside a native docker container

Solution Verified - Updated -

Issue

  • pstack does not print any stack output

    [root@master-0 ~]# docker run --rm -it registry.access.redhat.com/rhscl/nodejs-8-rhel7 bash
    bash-4.2$ 
    bash-4.2$ cat app.js
    var i;
    for (i = 0; true; i++) { 
    }
    bash-4.2$ node --prof app.js &
    bash-4.2$ ps aux
    USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    default       1  0.0  0.0  11824  1748 ?        Ss   10:28   0:00 bash
    default      18  104  0.1 845464 20168 console  Rl   10:29   2:17 node --prof app.js
    default      47  0.0  0.0  51708  1716 ?        R+   10:31   0:00 ps aux
    bash-4.2$ pstack 18
    bash-4.2$ 
    
  • Unable to attach GDB to a running process

Environment

  • docker - all supported versions
  • GNU Debugger (GDB)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content