Dockerode: write to container stdin

Created on 21 Dec 2016  路  5Comments  路  Source: apocas/dockerode

@apocas I'm currently attempting to pipe a readable stream to the stdin of my container while also piping stdout and stderr to a writable stream but i'm having some trouble. I'm attaching stream, stdin, stdout and stderr to the container after starting. This has proved to work for a stdout and stderr however not for stdin.

container.attach({stream: true, stdin: true, stdout: true, stderr: true}, function (err, stream) { stream.pipe(<some writable stream>); <some readable stream>.pipe(stream); });

I had some trouble understanding the stdin example code examples/run_stdin.js. My end goal is to have data from the readable stream pushing into the stdin of the container.

Thankyou

Most helpful comment

Also having this issue.

All 5 comments

Also having this issue.

@apocas Would this be possible using the exec.start command ? I've attempted the following as well to no avail. Where job.stdin, stdout, stderr are all streams attached to a websocket. The following does however pipe stdout and err through, my issue is that stdin is not reaching the container.

var opts = {
    "AttachStdin": true,
    "AttachStdout": true,
    "AttachStderr": true,
    "Tty": true,
    Cmd: ["./somescript.sh"]

}
container.exec(opts, function (err, exec) {
    exec.start({hijack: true, stdin: true}, function (err, stream) {
        container.modem.demuxStream(stream, job.stdout, job.stderr);
        job.stdin.pipe(stream);
    });
});

I moved to using container.attach with options:var opts = {'Detach': false, 'Tty': false, stream: true, stdin: true, stdout: true, stderr: true} and had no further issues.

@AlexanderCollins could you show me how you send the command to your container ? I'm having a lot of pain to do it

@JeromeVi see my answer in #38

Was this page helpful?
0 / 5 - 0 ratings