简体   繁体   中英

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?

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), eg 4a7afcdeb729 , then run the following:

docker exec -it 4a7afcdeb729 bash

This should open a new terminal session in the container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM