Conversation
tfoote
left a comment
There was a problem hiding this comment.
Thanks for this submission, it looks great to be able to provide this option. I had a few stylistic requests.
Can you explain a bit about how you're using this? I want to connect this to the mode setting and potentially force NON-INTERACTIVE in this case, or error if the mode is set explicitly to interactive.
|
Hi @tfoote . Thank you for your reply! Sorry, I was not aware that extensions should be in alphabetical order, and I have made the correction in the latest commit. I am using rocker for an autonomous driving system project (https://github.com/autowarefoundation/autoware/blob/2025.02/docker/Dockerfile). I want to be able to launch this container in the background, which is normally done through To reproduce my use case, run |
…ode for detach and no-tty present. Signed-off-by: Tully Foote <tullyfoote@intrinsic.ai>
…ommand Signed-off-by: Tully Foote <tullyfoote@intrinsic.ai>
|
Thanks for reordering, I have tweaked the command line parsing to handle mutual exclusion of --detach and interactive mode: YuqiHuai#1 Can you validate that works for you and then I think this will be good to go. |
|
@tfoote Thanks for making these changes! Unfortunately, with those changes, detach no longer works properly for my purpose. Setting --detach seems to automatically activate the non-interactive mode, and the container I am trying to get running doesn't run in the background when the mode is set to non-interactive. I am going to test a bit more to find the root cause. |
|
Interesting, I guess that maybe your program is detecting the pseudo tty of the pexpect interface and doing something different. I've been testing with:
Errors: I guess it would be possible to continue to keep the pexpect invocation but this seems like an odd edge case. And the intent of the interactive environment is to connect the users' keyboard. And when you're running headless it seems like if the executable is running or expecting user inputs that's not going to get very far. |
|
@tfoote I created a test image FROM ubuntu:18.04
CMD ["/bin/bash"]and tried to run different docker commands to see how I can achieve my goal (launching a container without necessarily entering it). It turns out I need flags After removing your changes of setting mode to non-interactive when detach is set, and adding code to set default to interactive, things are working as how I expect it to run. |
|
@tfoote I Just saw your comment after I posted the previous comment. I think the use case of Edit: Perhaps the best thing to do is default mode to non-interactive, no detach, but allow interactive and detach at the same time, I believe this would mean rocker uses default flags for docker. |
|
None of these cases keep the container running after the executable finishes. Some applications will finish after stdin is disconnected, and the only common example I know of this is interpreters like bash. For example I found a good overview of the distinctions here: https://stackoverflow.com/questions/47753047/docker-detached-and-interactive I see from your linked Usually the end of your docker command would be run my "service" aka a web server or the like. And the setup beforehand is to make sure all the dependencies are running in the container. To stop it from immediately ending you can pass a command like
This is the same as the default commands in I'm downloading your image but it's going to be a while to finish and be able to reproduce. |
|
@tfoote Thanks for taking a close look at the specific use case! I think your characterization of "I want the dev environment to be just running in the background" is accurate. Your example of using non-interactive mode with an additional "sleep infinity" command looks like it will achieve my goal but block the main terminal at the same time. I think we already understood the situation pretty well (i.e., using Back to this PR, I still believe having a detach flag helps, but making it mutually exclusive with interactive might be problematic because it is supported by docker. Do you think this detach plugin still contributes to rocker without making it mutually exclusive w.r.t. mode? |
|
The detach capability is something that I have other use cases that could be leveraged for example: https://github.com/opencv/bpc However I think that detached and interactive in the rocker sense are mutually exclusive, you cannot interact with a detached instance. There's a question of if the program things that there's still a stdin, which docker calls "interactive" this is an interesting distinction that I'm not sure I agree with.
The expectation of a non-interactive process is that it will run to completion. And if you want it to run in the background detached it does the same. We could add the -i --interactive option to do the stdin mounting separately from the --mode mechanism. Looking a little deeper it would be great to also enable rocker to keep track of the container and enable |
Implementing conflict feedback and resolution for default operating mode for detach and no-tty present
|
That all sounds good. I think it is ok for rocker and docker to have different interpretations of interactive. I tested my use case and found running non-interactive, detach, sleep infinity achieves my goal of keeping a container up and running in the back. When I re-attach and run Thank you for your time and consideration! I have merged your changes to the branch. |
tfoote
left a comment
There was a problem hiding this comment.
Great, I'm glad it's working for you now. I'll bring this in as is for now. But I'll open a feature request for extending the interactivity to potentially detached processes.
|
Thanks again for your time and consideration! I learned a lot about rocker and docker from our conversation. |
The comment is correct but this looks like it was changed in #320 by accident.
* Restore interactive as the default behavior The comment is correct but this looks like it was changed in #320 by accident. Co-authored-by: Scott K Logan <logans@cottsay.net> --------- Co-authored-by: Scott K Logan <logans@cottsay.net>
When rocker launches a docker container, there was no option to run it in detached mode. I added a plugin and a test case for this plugin that allows rocker to run container in detached mode.
All test cases in
test_extension.pypasses.