Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open multiple terminals in docker?

Tags:

docker

I need to launch two distinct processes on a docker container which requires two terminals.What is the best way to achieve this?

like image 645
Atlantic0 Avatar asked Sep 30 '16 14:09

Atlantic0


People also ask

Can I expose multiple ports Docker?

In your Dockerfile , you can use the verb EXPOSE to expose multiple ports.


2 Answers

You can run docker exec -it <container> bash from multiple terminals to launch several sessions connected to the same container.

like image 184
Elton Stoneman Avatar answered Sep 22 '22 00:09

Elton Stoneman


To expand on @eltonStoneman's great answer (For all those new docker folks like me):

  1. Open a docker terminal

  2. Get the image running as a container in the background: docker run -d -it <image_id>

    • Tip: docker ps will show the container_id that you just fired up from said image.
  3. Per @eltonStoneman's advice: docker exec -it <container_id> bash

    • Now your docker terminal is showing an interactive terminal to the container.
  4. Open up another docker terminal and perform step 3 to create another interactive terminal to the container. (Rinse and Repeat)

like image 24
isaacdre Avatar answered Sep 24 '22 00:09

isaacdre