How to get bash or ssh into a running container in background mode. The answer is Docker’s
attach command. So for my example above, the solution will be:
$ sudo docker attach 665b4a1e17b6 #by ID
$ sudo docker attach loving_heisenberg #by Name
For Docker version 1.3 or later: Thanks to user WiR3D who suggested another way to get a container’s shell. If we use attach we can use only one instance of the shell. So if we want open a new terminal with a new instance of a container’s shell, we just need to run the following:
$ sudo docker exec -i -t 665b4a1e17b6 /bin/bash #by ID
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.