How do i ssh into a running conatiner

0 votes

Suppose, I have two containers and I wish to execute certain commands only on the first container. How do i ssh into a running container?

Mar 12, 2019 in Docker by david
1,242 views

2 answers to this question.

0 votes

There is a docker exec command that can be used to connect to a container that is already running.

  • Use docker ps to get the name of the existing container
  • Use the command docker exec -it <container name> /bin/bash to get a bash shell in the container
  • Generically, use docker exec -it <container name> <command> to execute whatever command you specify in the container.
answered Mar 12, 2019 by Jason
0 votes

To bash into a running container,you could use the following command:

docker exec -it container_name /bin/bash
answered Aug 9, 2019 by Sirajul
• 59,230 points

Related Questions In Docker

+1 vote
1 answer
0 votes
1 answer

How do I get into a Docker container?

docker attach will let you connect to your ...READ MORE

answered Aug 10, 2018 in Docker by Kalgi
• 52,350 points
799 views
0 votes
2 answers

How do I force Docker for a clean build of an image ?

You could try this inorder to clean ...READ MORE

answered Aug 6, 2019 in Docker by Sirajul
• 59,230 points
10,732 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,738 views
+1 vote
2 answers

How do I copy a file from docker container to host?

Here is a way which you can ...READ MORE

answered Aug 28, 2018 in Docker by Damon Salvatore
• 5,980 points
28,607 views
+1 vote
2 answers

How do I run a docker image as a container?

You can run an image depends on whether you ...READ MORE

answered Sep 7, 2018 in Docker by Damon Salvatore
• 5,980 points
1,623 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP