[英]Docker linux: How to start multiple console/terminals for one running container?
I'm using below command to run docker, 我正在使用下面的命令来运行docker,
docker run -it centos:6.5 bash
It starts bash with root user, no problem. 它以root用户启动bash,没问题。
But I wish to have multiple terminals to connect to it and do different things. 但我希望有多个终端连接到它并做不同的事情。 I found
attach
command will only duplicate a terminal window which all input/output will be propagated. 我发现
attach
命令只会复制一个所有输入/输出都会传播的终端窗口。 It doesn't solve my requirement. 它没有解决我的要求。
How to do this? 这该怎么做?
Once the container is running, you should be able to use docker exec
to run an additional Bash session in the same container. 容器运行后,您应该能够使用
docker exec
在同一容器中运行另一个Bash会话。
When your first container is running, use docker ps
to find its Container ID (the first column in the docker ps
output), eg 4a7afcdeb729
, then run the following: 当您的第一个容器运行时,使用
docker ps
查找其Container ID ( 4a7afcdeb729
docker ps
输出中的第一列),例如4a7afcdeb729
,然后运行以下命令:
docker exec -it 4a7afcdeb729 bash
This should open a new terminal session in the container. 这应该在容器中打开一个新的终端会话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.