User:Tsu2/docker-enter
A Running Docker Container, How to access?
The standard documentation describes installing an SSH daemon and remotely connecting to it, optionally with X over SSH.
A better and possibly more secure way is to access the container's console directly without using a network connection. This is also practical because not all containers set up with a working network interface by default and for those if you don't remember to install required remote access components before exiting the first time, that container may become unusable following official documentation.
Simply Displaying the Container's console
The following command is described in the official documentation, but only displays and is not interactive
docker logs <containername or containerid>
Use nsenter
This is by far the best solution I have found to date. The following instructions are based on the author's blog page here. In fact, I recommend reading his blog post now and then come back to this page for the condensed and simpler instructions. http://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/
The simple instructions, modified which should work on any platform (not just an openSUSE Host)
Download and install the Docker image
The following command is a bit unusual... It downloads the Docker image to the Host but instead of invoking with a Docker command is instead placed in the Host's /usr/local/bin directory so you can run it as a simple binary on its own instead of within Docker
docker run -v /usr/local/bin:/target jpetazzo/nsenter
Opening the Default Console in your Container
This is a 2 step procedure
PID=$(docker inspect --format {{.State.Pid}} <container_name_or_ID>)
Followed by (note the following diverges from the official instructions)
docker-enter <containerid or containername>
When you're done and want to leave the container, as alwasy just type "exit" which should leave the container running until you invoke "docker stop <containername>"
exit
So cool.
And it works in the most simple way with containers which practically eliminates any dependencies.