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 recommended workflow to have the process running, occasionally attaching to it to make some changes, and then detaching?
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 recommended workflow to have the process running, occasionally attaching to it to make some changes, and then detaching?
To detach the tty without exiting the shell, use the escape sequence Ctrl+p + Ctrl+q.
more details here: https://docs.docker.com/engine/reference/commandline/attach/
I think this should depend on the situation.Take the following container as an example:
(1) Use "
docker attach
" to attach the container:Since "
docker attach
" will not allocate a new tty, but reuse the original running tty, so if you runexit
command, it will cause the running container exit:So unless you really want to make running container exit, you should use Ctrl+p + Ctrl+q.
(2) Use "
docker exec
"Since "
docker exec
" will allocate a new tty, so I think you should useexit
instead of Ctrl+p + Ctrl+q.The following is executing Ctrl+p + Ctrl+q to quit the container:
Then login container again, you will see the
bash
process in preaviousdocker exec
command is still alive (PID is 15):Check out also the
--sig-proxy
option:Then use
CTRL+c
to detachTo detach from the container you simply hold Ctrl and press P + Q.
To attach to a running container you use:
I had the same issue, ctrl-P and Q would not work, nor ctrl-C... eventually I opened another terminal session and I did "docker stop containerid " and "docker start containerid " and it got the job done. Weird.
when nothing else works, open a new terminal then: