Docker: reattach to `docker exec` process

后端 未结 2 1603
梦谈多话
梦谈多话 2021-01-11 14:55

If I use docker exec to fire up a shell,

docker exec -ti  /bin/bash

I could use Ctrl+p Ctrl+q to detach this

2条回答
  •  难免孤独
    2021-01-11 15:25

    Sadly, this is not possible yet; see this issue on GitHub. I've also wanted this functionality, but at the moment it seems like there's no direct way to do this.

    A workaround has been proposed, to take care of the case where you're accessing a box via ssh and running docker exec on the remote box (or, for the case where your terminal emulator is unstable and may crash on you): Always run your docker exec commands inside screen or tmux. If you do this, whenever you get detached from the screen/tmux session, you can re-attach to it later and still have your docker exec commands accessible. (this is a bit different than what was suggested by @vodolaz095, since it involves running screen or tmux outside the container, making it suitable for use with containers that don't run screen/tmux as their main process)

提交回复
热议问题