-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Control-C while running docker attach
should not terminate the Docker container
#2855
Comments
cc @shykes |
OTOH, if I do Maybe |
@jpetazzo This is simple (to me at least):
This is symmetric and without surprise: Ctrl-C detaches |
p.s. I think your suggestion is really nice, but this should not be the default. IMO, an argument to |
@lhazlewood To be consistent with every other docker command Ctrl+C terminates the process/container and Ctrl+P+Q detaches. Incase you don't know, docker run == create, start, attach. |
The behavior you are looking for can be achieved with On Thursday, December 19, 2013, Les Hazlewood wrote:
Guillaume J. Charmes |
@crosbymichael I'm aware of how docker run works, but thanks for refreshing :) If I attach to an already-running container, the intuitive expectation is that if I want to detach, I would use For command-line suite design (like @creack Bottom line: the command line tool should not surprise the end-user. It is a surprise that the container is stopped when all you want to do is detach. No one would know to try In any event, that's my .02. Thanks for all the great work you guys are doing on Docker - please keep it up! |
Follow up: Running VirtualBox on a Mac, I cannot execute I'd love to see this fixed! :) |
Les you make a good point. I'm the one to blame for the "carpet-bomb consistency" across run, start and attach. My reasoning was that the default behavior should be consistent. But in the case of attach I see the problem. Ironically now I worry about causing even more damage by "flip-flopping" and changing back the attach behavior. What do you think? On Thu, Dec 19, 2013 at 6:15 PM, Les Hazlewood [email protected]
|
@shykes No blame necessary! That's why the community is so awesome - so feedback like this hopefully makes things better for everyone. As for 'flip-flopping', I don't think that will be a problem. The latest docs still reflect that Control-C detaches from an already-running container, so not many people probably know about this yet. And it's only been in effect for two point releases (0.6.6 and 0.6.7), so it probably didn't affect many people. If you can get this out in 0.7, that'd be ideal, and then most would be 'none the wiser'. Finally, because Docker is not yet at 1.0, I see this as much less harmful, especially with the (hopefully minimal) impact. Plus, as a nice bonus, you wouldn't have to change the existing docs :) Again, you guys rock - keep up the great work. Docker is coming along beautifully! |
in trying to answer https://groups.google.com/forum/#!topic/docker-user/BEdffdKBE9w I was just testing 0.9.0, and got the following I was expecting that I could use --sig-proxy the same way in run (to essentially allow me to choose to make a daemonised container from run (or type exit) but it looks like --sig-proxy is not consistent between run and attach. can someone please help me work out how to document it
|
Sorry if I'm crashing a wrong discussion. I just found that
I start a long running process with I can use the ^P^Q shortcut to detach from the container. If I then But when using I think either the docs are misleading on this point or it doesn't work as expected. |
I just ran docker attach and tried to control+c and I couldn't get out. I'm fairly new to docker but my expectation was for it to detach or at least stop what I did. |
Shouldn't this issue be closed? I'm using docker 0.11.1 and when running containers with -t, I'm able to detach using Ctrl+C without the container being stopped. |
On 0.11.1:
I don't have a strong opinion on what should be the "right" behavior. I still think that some people will expect ^C to detach, others will expect ^C to terminate the container. Parallel: look at screen or tmux. When attaching to a session, ^C sends ^C inside the session; it doesn't detach. |
The current behavior is weird, why would anyone one want it as it works right now where you can not exit an attach without killing the terminal from another session? |
I'm surprised this issue is still open. Ctrl-C should detach. Use Any updates from the Docker team to getting this fixed? |
I found this discussion via google after I got "stuck" in docker attach. Thanks for suggestion some solutions, IMO Ctrl+C should detach, there is docker stop if I want to stop the container |
Hi guys! Any update on this? This continues to be a frustration point (and by the looks of it, plenty of others). Thanks! |
I'm waiting on this, too. |
Detaching is more analogous to edit: I guess I should clarify that I mean, I can't think of any scenario where you should be attached to a container, where accidentally |
@nathanleclaire I believe you're debating an implementation detail and not addressing what people actually want. The reality is that people consider the 'attach' behavior as a separate process from the underlying docker container. It may not be, but that's just an implementation detail. This means that if I attach, I want the attach process to cancel - not the underlying docker process. "I can't think of a situation where accidentally killing a process you are attached to with ^C would be a Very Bad Thing" Um. Try telling that to anyone that runs docker in production. :) It is very easy for a sys admin to |
Why would you be attaching to containers for this purpose? Just curious. And have you considered |
+1 to @lhazlewood. That was exactly my thinking and my confusion about this behavior. |
+1 to @lhazlewood but I concur that nsenter is a nice choice for many (not all) tasks. Making After all, I don't think anyone would like to have their production server shutdown when they |
Scenario:
If you did not have this option, the container would not terminate. ^P^Q terminates the attach today, if you just want to do that.
|
Add more info on attach inspired by discussion in #2855
now that we have docker exec is this still an issue? |
yes it is @jfrazelle. If I want to see active server logs I'll use |
@jtmarmon That's what |
but that's what "docker logs -f" is for :) |
haha okay you got me, but my point still stands. there are other use cases for attaching to a running process. seems a bit odd to be able to kill a container process with absolutely no warning imo. also man you guys are fast |
I feel like we need to decide is this intentional or not (I am heavily leaning towards desired behavior) and document as so, so that people know. |
Documentation has been already been corrected. Although this is by design, #2855 (comment) nicely summarises my thoughts. Perhaps a similar approach as nodeJS would accommodate both "camps"?
(my final suggestion on this. I'm too opinionated on this, think it's up to the maintainers to vote/make a decision) |
This was extremely surprising to me. |
Also |
+1 to @lhazlewood ^C should detach |
There's currently a PR to make the key-combination configurable; #15666 |
Removing the "needs attention" label, there's now a PR |
I've been surprised too, that |
+1 to @lhazlewood ^C should detach |
Well, good news, you can now do Closing as the current behavior is the "correct" behavior and is in line with the how SSH handles detaching (albeit different key sequence), and also the detach sequence can be changed to use ctrl-c (or any other combination) people want. |
For more info on the "configurable detach keys", see the pull request: #15666 |
+1 for ^C should detach by default. |
@antoine-lizee: this is not going to change. You can set this value yourself both per command with a flag as well as a default via config file. |
+1 to @lhazlewood ^C should detach I am logged into a into a live container to check what's going on in there. Intuitive reaction ^C to leave. |
+1 to @lhazlewood ^C should detach |
I'm locking this issue; the default key-combination is not going to change, and you can now set your own default using a configuration file #15666. I understand that for some people |
Per this Pull Request thread based on 0.6.5 to 0.6.7 functionality:
I believe most people feel that that if you run
docker attach
thatControl-C
should detach you and never shut down the container - in all cases. Stopping the container is whatdocker stop
is for. It is important to have feature symmetry and not surprise people:IMO, end-users shouldn't be surprised by default behavior. When you
docker attach
, it is a surprise thatCtrl-C
kills the container, because you expect the attachment to discontinue (i.e. 'detach'), not stop the container entirely - since that is whatdocker stop
is for.(now, if an end-user wants to terminate the container from attachment with
Control-C
, maybe that is supported by adding an explicit argument to thedocker run
command. This just shouldn't be the default. However, I presume that this extra feature wouldn't be worth working on until people ask for it).The text was updated successfully, but these errors were encountered: