Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker linux: How to start multiple console/terminals for one running container?

I'm using below command to run docker,

docker run -it centos:6.5 bash

It starts bash with root user, no problem.

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. It doesn't solve my requirement.

How to do this?

like image 621
Troskyvs Avatar asked Mar 21 '17 08:03

Troskyvs


1 Answers

Once the container is running, you should be able to use docker exec to run an additional Bash session in the same container.

When your first container is running, use docker ps to find its Container ID (the first column in the docker ps output), e.g. 4a7afcdeb729, then run the following:

docker exec -it 4a7afcdeb729 bash

This should open a new terminal session in the container.

like image 142
nwinkler Avatar answered Nov 11 '22 23:11

nwinkler