Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exec with Stdin #325

Closed
jsrun opened this issue Jan 8, 2017 · 0 comments
Closed

Exec with Stdin #325

jsrun opened this issue Jan 8, 2017 · 0 comments

Comments

@jsrun
Copy link

jsrun commented Jan 8, 2017

Hi all, I would like to know how it would be possible to use the exec command and in case of commands that require data input I can send, for example:

In case I get the commands via socket.io and send to the container via exec, and it works perfectly more in the case of apt-get install for example that needs digital Y / N when I send the command it's like another "thread"

socket.on('stdin', function (data) {
    container.exec({Cmd: data.split(" "), AttachStdin: true, AttachStdout: true}, function(err, exec) {
        exec.start({hijack: true, stdin: true}, function(err, stream) {
            stream.on('data', function(chunk) {
                io.sockets.emit("stdout", chunk.toString());
                console.log(chunk.toString());
            });

            stream.on('error', function(err) {
                io.sockets.emit("stderr", err.toString());
                console.log(err.toString());
            });

            stream.on('end', function(chunk) {
                io.sockets.emit("enable");
            });

            docker.modem.demuxStream(stream, process.stdout, process.stderr);
        });
    });
});
@apocas apocas closed this as completed Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant