0

I know many would say that this is a redundant question. But I am putting this thread as my last straw. I have gone through many threads in this community regarding my query, but was not able to achieve what I need.

Here's what I need to do.

  1. Make docker containers such that it's IP would come in the same network as my host's. Just like a virtual machine in bridged network.

  2. I need to be able to ssh to these dockers via external machines in my host m/c's network.

  3. I simple replace Virtual Machines with docker in my system. And for that I need to ssh them just like I have been doing with the Virtual Machine nodes.

What I have tried?

  • Able to ssh the container via my host m/c. Where I installed ssh on container and enabled the port 22. Also I set UsePAM to no in /etc/ssh/sshd_config file.

  • Followed Ben Whaley on this thread.
    I tried IP aliasing, But after all that, when I did ssh <IP address> -p 5000 , I got ssh: connect to host <IP address> port 5000: Connection refused error.

  • Tried to follow Regan on this page. But those documents were pulled down, and The documents that I found was not helpful either, as they were proving hard for me to understand.

  • Tried to make a bridge from this reference. But there too, my virtual0 bridge was not taking any IP address. If I manually give one to it, it wasn't accepting any connection through that IP.

Please can anyone help me out here?

I just need to replace my VM's with the docker containers so that I can improve my resource utilization.

Community
  • 1
  • 1
  • First question: What is your Host OS? If you are using a Mac or Windows, you are still using a VM. – OneCricketeer Apr 27 '16 at 07:28
  • My host OS is CentOS 6.7 –  Apr 27 '16 at 07:33
  • And you want to SSH via port 22 to all the containers? (Not really possible over one network adapter) Or you want each container to act like a new machine in your network? – OneCricketeer Apr 27 '16 at 07:38
  • 2
    Sidenote: [this post](https://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/) is worth a read. Essentially, you should never need to go into the containers. And if you did, then SSH to the machine running Docker and attach to the container from there – OneCricketeer Apr 27 '16 at 07:42
  • @cricket_007, I don't want to bound to port 22 actually. I just mentioned that as port 22 is usually closed in containers, and to ssh the container, that port needs to be open. My objective is the same as I mentioned in my question. I am not bind to any approach. –  Apr 27 '16 at 08:51
  • And regarding accessing the container via ssh to host, i have thought about that approach, But the situation is that my system/program is used to accessing the nodes via ssh, if I need to add host access, I have to make a lot of changes in my code. –  Apr 27 '16 at 08:53
  • You would need less changes by opening SSH access to the machine running Docker than opening SSH of all current and future containers and managing exposed ports for that. You still haven't provided your use case for needing SSH access to any container. The link in the previous comment pointed out is likely not necessary – OneCricketeer Apr 27 '16 at 13:09
  • I need to use the containers as "on demand nodes" for job schedulers (say OGS). And I can do that by providing the IP of the containers to the job schedulers. I agree to the point you made as exposing so many ports simultaneously is definitely not a good idea, but I can't see any way around this problem. If although I can make the host node act as NAT, and all the containers as nodes in the internal network, this might work. But I haven't dig enough into that side. –  Apr 28 '16 at 04:42

0 Answers0