如何从容器外部在Docker容器中创建并连接到TTY?

时间:2019-01-04 13:11:34

标签: javascript docker terminal tty

我希望在GDB中调试(在Docker中运行)的二进制文件的输入/输出(tty)作为NodeJS流。

GDB可以使用tty <tty>命令将其输出与二进制文件的输出分开。我想与此TTY进行交互,但是它在Docker容器中。反正有公开TTY吗?

到目前为止,我在从容器执行(通过Dockerode)并读取输出流时尝试了chvt,但是它不起作用。

使用gdb -i=mi --tty=<some tty>在容器中运行GDB

我想使用例如主管:

let exec:Exec = await container.exec({ AttachStdin: true, AttachStdout: true, AttachStderr: true, Cmd: ['chvt', '69'], Tty: true }); let execProc = await exec.start({Tty: true}); let sock = execProc.output.connection; sock.pipe(<somewhere>); //tty of binary running in GDB can be interacted via pipe

1 个答案:

答案 0 :(得分:0)


let containerExecStream = async (container: Container,cmd: string[]) => {
    let exec = await container.exec({
        AttachStdin: true,
        AttachStdout: true,
        AttachStderr: true,
        Tty: true,
        Cmd:['bash', '-c', 'socat pty,raw,echo=0,link=/dev/gdbout,waitslave -']});
    let out = await exec.start({Tty: true});
    return <Socket>out.output.connection;
}
相关问题