Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to start a shell session in a running container (without ssh)

Tags:

docker

I was naively expecting this command to run a bash shell in a running container :

docker run "id of running container" /bin/bash 

it looks like it's not possible, I get the error :

2013/07/27 20:00:24 Internal server error: 404 trying to fetch remote history for 27d757283842 

So, if I want to run bash shell in a running container (ex. for diagnosis purposes)

do I have to run an SSH server in it and loggin via ssh ?

like image 970
Max L. Avatar asked Jul 28 '13 00:07

Max L.


People also ask

Do you need a SSH server to get bash shell inside a container?

You need an SSH server to get a bash shell inside a container.

How do I start bash in a container?

In order to start a Bash shell in a Docker container, execute the “docker exec” command with the “-it” option and specify the container ID as well as the path to the bash shell. If the Bash is part of your PATH, you can simply type “bash” and have a Bash terminal in your container.

How do I get into the container shell remotely?

Step 1: Enable remote access for a containerLocate and select the desired workload. Navigate to Manage Your Instances, and then use the slider to enable Remote Management. Above Manage Your Instances, navigate to Instances, and then select the desired instance.


1 Answers

With docker 1.3, there is a new command docker exec. This allows you to enter a running docker:

docker exec -it "id of running container" bash 
like image 145
Michael_Scharf Avatar answered Oct 04 '22 18:10

Michael_Scharf