This problem is quite similar like this, but I am still having problems:
I run a container with:
docker run -d CONTAINER
then I attach to it with
docker attach NAME
but I cannot exit it, not with CTRL-C, nor with CTRL-P + CTRL-Q (like suggested in the similar question above)
I have to kill -9 PID
to exit it...
What am I doing wrong?
Docker version 0.6.7, build cb48ecc
Ubuntu 3.8.0-33-generic #48~precise1-Ubuntu
Just Stopping the Container If you want to stop and exit the container, and are in an interactive, responsive shell - press ctrl+d to exit the session. You could as well type the exit command. TL;DR: press ctrl+c then ctrl+d - that means, keep the ctrl key pressed, type a c, and let go of ctrl.
How do you exit a docker container? This way, you get an interactive shell and you are immediately logged into the OS running as container. To exit from this running container, you can use ctrl+c, ctrl+d or enter exit in the terminal.
To stop a container, use CTRL-c . This key sequence sends SIGKILL to the container. If --sig-proxy is true (the default), CTRL-c sends a SIGINT to the container. If the container was run with -i and -t , you can detach from a container and leave it running using the CTRL-p CTRL-q key sequence.
To start a container in detached mode, you use -d=true or just -d option. By design, containers started in detached mode exit when the root process used to run the container exits, unless you also specify the --rm option.
As Jérôme Petazzoni mentioned in docker-user group:
Actually, you can SIGKILL the client, and reattach later. However, this will disrupt stdin (the container will see EOF on stdin, and if it cares about stdin, e.g. if it's a shell, it will exit). To recap: docker run -t -i → can be detached with ^P^Q and reattached with docker attach docker run -i → cannot be detached with ^P^Q; will disrupt stdin docker run → cannot be detached with ^P^Q; can SIGKILL client; can reattach with docker attach
You should attach
to the container using the --sig-proxy=false
option like this:
docker attach --sig-proxy=false NAME
Then you can use CTRL
+C
to exit without stopping the container itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With