-
-
Notifications
You must be signed in to change notification settings - Fork 461
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
Closing stdin stream #53
Comments
Something like this? #8 :) |
Not quite. I am attaching stdin with StdinOnce and AttachStdin set to true. The result is that I am getting an HttpDuplex which does not have destroy(). The exact code is here: |
Oh, Yeah attaching to stdin will use HttpDuplex. Have you tried using httpduplex's end? https://github.com/apocas/docker-modem/blob/master/lib/http_duplex.js#L44 |
Yes, I did. However the |
That's weird. |
Using something similar to this: I was able to close the stdin stream and even reattach later directly on docker. |
I'm having trouble closing stdin as well. I'm trying to emulate running this: Here's a gist that should print Notice when you change line 14 to
it outputs Thanks for all your hard work @apocas! Let me know if there is anything else I can provide to make this easier to debug. |
I am also finding that |
Here's a repro. First, pull Them run this file (coffeescript, but easily compiled to JS if you like): docker = new (require('dockerode'))(socketPath: '/var/run/docker.sock')
createContainer = (i) ->
console.log "creating container #{i}"
docker.createContainer {
Cmd: '/bin/bash'
Image: 'ubuntu:12.04'
OpenStdin: true
Tty: true
}, (err, container) ->
console.log "attaching to container #{i}"
container.attach {
stream: true,
stdin: true,
stdout: true
}, (err, ttyStream) ->
setTimeout ->
console.log "ending container #{i} tty stream"
ttyStream.end()
container.remove { force: true }, ->
console.log "container #{i} removed"
, 5000
for i in [0..20]
setTimeout createContainer, i * 250, i Now, lsof your still-running node process (it won't terminate, which is also a red flag):
20 open FDs still. P.S. here's a JS file if you just want to use that: var createContainer, docker, i, _i;
docker = new (require('dockerode'))({
socketPath: '/var/run/docker.sock'
});
createContainer = function(i) {
console.log("creating container " + i);
return docker.createContainer({
Cmd: '/bin/bash',
Image: 'ubuntu:12.04',
OpenStdin: true,
Tty: true
}, function(err, container) {
console.log("attaching to container " + i);
return container.attach({
stream: true,
stdin: true,
stdout: true
}, function(err, ttyStream) {
return setTimeout(function() {
console.log("ending container " + i + " tty stream");
ttyStream.end();
return container.remove({
force: true
}, function() {
return console.log("container " + i + " removed");
});
}, 5000);
});
});
};
for (i = _i = 0; _i <= 20; i = ++_i) {
setTimeout(createContainer, i * 250, i);
} @apocas would really love your eyes on this one |
@apocas regarding your fix, are we supposed to call |
end I just added destroy to pass this functionality from res and req in case one day we need it :) |
docker-modem version published: v0.1.20 Update docker-modem to have this fixed :) |
After attaching and writing data to stdin I need to close it somehow. I have some code that is being executed and expects the stdin in the container to be closed at a certain poinrt. Is there a way for this to be accomplished?
The text was updated successfully, but these errors were encountered: