I can attach to a docker process but Ctrl+c doesn\'t work to detach from it. exit
basically halts the process.
What\'s the recomm
To detach from the container you simply hold Ctrl and press P + Q.
To attach to a running container you use:
$ docker container attach "container_name"
If you only need the docker process to go in the background you can use
Ctrl + Z
Be aware that it is not a real detach and it comes with a performance penalty.
(You can return it to foreground with the bg
command).
Another option is to just close your terminal, if you don't need it any longer.
To detach the tty without exiting the shell, use the escape sequence Ctrl+P followed by Ctrl+Q. More details here.
Additional info from this source:
^P^Q
and reattached with docker attach^P^Q
; will disrupt stdin^P^Q
; can SIGKILL client; can reattach with docker attachIf you just want to make some modification to files or inspect processes, here's one another solution you probably want.
You could run the following command to execute a new process from the existing container:
sudo docker exec -ti [CONTAINER-ID] bash
will start a new process with bash shell, and you could escape from it by Ctrl+C directly, it won't affect the original process.
docker ps
docker kill ${containerId}
I'm on a Mac, and for some reason, Ctrl-p Ctrl-q would only work if I also held Shift