2

I illustrate my question with the help of docker containers but this example is orthogonal to the rest of the problem. In fact any program that allows the use of bridge interfaces and ssh would do.

I use a Docker container which runs a sshd daemon in the background which is spawned by supervisord which runs in the foreground. I mainly use ssh to have a secure way of X11-forwarding without having to bind mount /tmp/.X11-unix into may container and totally exposing the socket to the container. If I use docker top containername right after I started the container I get the following output:

UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                4732                535                 1                   19:56               ?                   00:00:00            /usr/bin/python /usr/bin/supervisord
root                4745                4732                0                   19:56               ?                   00:00:00            /usr/sbin/sshd

which is as expected. Now, I exposed port 22 on the container to port 5000 on the host. Hence, I can login into my container using ssh -X username@localhost -p 5000. I know how ssh works when client and host are different computers and on different networks but I have some questions when client and host are one the same computer (in my case client is my normal machine and host is the container on my normal machine). I know that docker sets up a bridge between the physical network device on my normal machine and the virtual network device on my machine.

  1. But how exactly do my normal machine and the container`communicate with each other? Do they use the IP addresses assigned to them by the bridge device and communicate via those?

  2. How are the ports involved in this process do they remove the need to use IP addresses?

  3. Is there a most efficient/recommended way of using ssh when client and host are on the same machine and configured in the way I just outlined.

Extensive internet search did not reveal sufficient answers. That being said I, of course, would not assert that such a site does not exist!

closed as off-topic by slm Aug 15 '14 at 12:27

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – slm

  • Try the answer to this very similar question over on Server Fault. – garethTheRed Aug 15 '14 at 12:07
  • I did a crosspost and flagged this post for moderator attention immediately to be either linked or removed as the question seemed appropriate for both sides. We just need to wait for a moderator. – lord.garbage Aug 15 '14 at 12:09

Browse other questions tagged or ask your own question.