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

docker.run closes the streams when the container stops if Tty: false #559

Closed
kevinlul opened this issue Mar 11, 2020 · 3 comments
Closed
Labels

Comments

@kevinlul
Copy link

Following the example in the README to separate stdout and stderr for docker.run, after the promise resolves or the callback is called, the streams are closed. This shuts off the entire process' outputs. A subsequent call to docker.run in the same fashion will eventually crash the process with ERR_STREAM_WRITE_AFTER_END, since stdout and stderr were closed.

@adamburgess
Copy link

Had this same problem...
easy fix is to use a passthrough so the final stream isn't closed:

const stdout = new stream.PassThrough();
stdout.pipe(process.stdout, { end: false });

docker.run(..., [stdout, stdout], ...);

this doesn't really seem to be dockerode's fault fyi, process.stdout/err don't get closed when you pipe to them, only when you explicitly call end(). Like, even if you use

stdout.pipe(process.stdout, { end: true })
stdout will still stay open... nodejs/node#7606 (comment)

@kevinlul
Copy link
Author

At least the README should be updated, maybe to match your sample, because if example usage ends up causing bad behaviour then it makes for a poor example.

@stale
Copy link

stale bot commented Apr 25, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Open a new issue if needed.

@stale stale bot added the stale label Apr 25, 2022
@stale stale bot closed this as completed May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants