重新连接到容器,就像原始的“ docker run” [英] reconnect to container as the original "docker run"

查看:111
本文介绍了重新连接到容器,就像原始的“ docker run”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些容器正在运行,有时在终端中失去连接。容器仍在正常运行。如何重新连接到samme用户进程?

I have some containers running and once in a while the connection is lost in the terminal. The container is still running perfectly. How do I reconnect to the samme user process?

问题是:
当我执行 docker exec -it bash ,我得到一个新的root用户。但是然后我需要停止原始用户开始的应用程序才能将其放入此bash中。

The problem is: When I do docker exec -it name bash, I get a new root user. But then I need to stop the applications the original user started to get them into this bash.

如何重新连接到原始正在运行的用户进程/ bash。

How do you reconnect to the original running user process/bash.

信息:使用Mac终端。 / p>

info: using mac terminal.

推荐答案

您需要使用 docker attach<容器ID>

是指: man docker-attach


docker attach命令允许您使用容器的ID或名称将容器附加到正在运行的
容器,以查看其正在进行的操作
的输出或以交互方式进行控制。您可以同时将
附加到同一包含的进程多次,屏幕共享样式,或快速查看守护进程
的进度。

The docker attach command allows you to attach to a running container using the container's ID or name, either to view its ongoing output or to control it interactively. You can attach to the same contained process multiple times simultaneously, screen sharing style, or quickly view the progress of your daemonized process.

您可以使用CTRL-p CTRL-q(用于安静退出)或CTRL-c从容器分离(并使其运行),这会将SIGKILL
发送到当您连接到容器上并退出其主要流程时,该流程的exi代码将返回给客户端。

You can detach from the container (and leave it running) with CTRL-p CTRL-q (for a quiet exit) or CTRL-c which will send a SIGKILL to the container. When you are attached to a con‐ tainer, and exit its main process, the process's exit code will be returned to the client.

这篇关于重新连接到容器,就像原始的“ docker run”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆