Skip to content

How I can get process ID (PID) of a executed command? #796

Description

@carromeu

I am using Dockerode to create a Web Terminal. That works fine. However, when user close console, I need to kill de ash, bash, dash or sh process attached to Xterm. To this, I need to store the PID in the moment of exec command:

const exec = await container.exec({
  Cmd: [ '/bin/' + command ],
  AttachStdin: true,
  AttachStdout: true,
  User: 'root',
  Tty: true,
})

const stream = await exec.start({ stdin: true, hijack: true, Detach: false });

I try the inspect command (const data = await exec.inspect()), but the PID returned is not of process.

Is there a way to get this PID by Dockerode?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions