In Docker 1.1.2 (latest), what's the correct way to detach from a container without stopping it?
So for example, if I try:
docker run -i -t foo /bin/bash
ordocker attach foo
(for already running container)
both of which get me to a terminal in the container, how do I exit the container's terminal without stopping it?
exit
and CTR+C
both stop the container.
I consider Ashwin's answer to be the most correct, my old answer is below.
I'd like to add another option here which is to run the container as follows
You can then enter the container and run bash with
No need to install sshd :)
If you attached through
docker attach
, you can detach by killing the docker attach process. Better way is to use sig-proxy parameter to avoid passing the Ctrl+C to your container :Same option is available for
docker run
command.If you just want see the output of the process running from within the container, you can do a simple
docker container logs -f <container id>
.The
-f
flag makes it so that the output of the container isfollowed
and updated in real-time. Very useful for debugging or monitoring.