-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
runc (create and start) or run detached (-d) tty issues #1218
Comments
I tested with lates HEAD with console-rewrite fixes and I can repeat the issue. |
This issue is same as #1202. |
@ronin13 Unfortunately your fix won't work with detached containers. The reason why To be clear Your fix is (unfortunately) not the answer. According to @avagin this is a CRIU issue (which I err on the side of agreeing with), but I also feel like we should be doing something less insane with |
@cyphar Thanks for the detailed review. With the 'sh -c ""while :; do date; sleep 3; done"' in (config.json) I was able to verify that process is able to write with https://gist.github.com/ronin13/1ef838ced63e562b458daa05320be7b0 with the process started as Regarding
I have seen detach (https://sourceforge.net/p/detach/wiki/Home/) doing this for stdin when running like
However, since stdout still points to a tty, it writes to stdout even in detached case much like runc. So, probably, even the stdout needs to be null-ed as you mentioned above. And regarding the CRIU issue, a consequence of this is that with detached run it writes to tty where it is invoked (so date is repeatedly printed to terminal where 'run -d' is invoked from), which may not be nice, and so, I feel has a scope beyond CRIU. With docker, I have seen it writing to anon pipes (like in my first comment), and then with docker attach it attaches client's (0,1,2) to those pipes, and on detach, they go back to writing to those pipes. In any case, it would also be good to document this since people may stumble with runc checkpoint/restore failing even with 'terminal:false' while running in detached mode. |
IIRC
Hmm I actually assumed that
Yeah, it's a runC issue. We shouldn't be passing host terminal descriptors to containers. It's just not safe IMO. There's been a lot of "fun" discussion about that in opencontainers/runtime-spec#513 (specifically look at opencontainers/runtime-spec#513 (comment)).
That's because of how Docker/containerd work. In effect, containerd-shim sets it's own stdio to be pipes that are then relayed to Docker. Trust me, it's not very pretty code (especially now that
To be honest, I'd prefer fixing it as opposed to documenting behaviour that is IMO quite dangerous. |
Hello. I'm having exactly the same problem after 3 years. I tried to workaround it by specifying exec 0<>/dev/null 1<>/dev/null 2<>/dev/null Hope this helps someone. BTW, why not replace all standard streams with |
Even with 'terminal:false' (config.json), , runc checkpoint is failing for me (as in #87) with 'runc create...; runc start' or 'runc start -d'
However, it works fine with 'runc start ' (without detach). Also noticed that setupIO in utils_linux.go has 'r.detach || r.create' passed to it. (should 'runc start' attach again?)
Moreover, with runc start -d, the stdout of the program (date) was being written to the terminal, even though it was detached.
ls -l /proc/$pid/fd
showed the file descriptors (0,1,2) pointing to /dev/pts/XX.With docker detached mode, they all point to pipe (to be attached again with
attach
).So, I tested with
Now, I see that runc checkpoint works fine. Also, 'run -d' doesn't write to terminal either. And, fds look like:
The HEAD I tested with is, 47ea5c7 on master.
The text was updated successfully, but these errors were encountered: