reattach to docker container detached because of ssh disconnection

时间:2019-01-07 13:12:06

标签: docker ssh

I conneceted to my server using ssh and then attach to my container using docker exec -it my-container bash. After some minutes my ssh connection got frozen and I lost my container bash session which is running some important process. Is there any way to reattach my previous bash session inside my running container after I connect again to my server using ssh?

1 个答案:

答案 0 :(得分:0)

没有办法做到。

下次您应该

1-登录到您的计算机

2-启动一个名为tmux的会话($ tmux new -s myname)

3-在tmux内部运行命令($ docker exec -it my-container bash)

4-当ssh连接冻结时,您可以返回相同的tmux会话($ tmux a -t myname)