7

Here is the scenario.

I have three containers.

Container1, container2, and container3 (Ubuntu based image) where the container2 acts as a router between container 1 and container2.

I will run a server program in container3 which runs indefinitely but when I initiate the connection from the client,I will collect some statistics, for the next run, I need to change some parameters in the server (using tc netem) and re run the test.

I need to SSH and execute a command in Middlerouter as well as in container3 before I go to next run.

I cannot login with SSH because it says connection refused. I have a port 22 exposed to all the containers

Here is the image of containers running enter image description here

P.J.Meisch
  • 18,013
  • 6
  • 50
  • 66
AmithRc
  • 89
  • 6
  • Could you provide us with your Dockerfiles, the command you tried to execute, the stacktrace and so on ... It is difficult to help with this little information. – Mornor Apr 27 '18 at 14:15
  • Check: [How to get into a docker container?](https://stackoverflow.com/questions/30172605/how-to-get-into-a-docker-container). You might also want to take a look at [this](https://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/). – tgogos Apr 27 '18 at 14:17
  • @Mornor, Thank you, I will post and update the post. – AmithRc Apr 27 '18 at 14:36
  • @tgogos Thanks for the link, As I said I am trying to SSH from the container to container as opposed to host to container. docker exec will help to execute the shell commands from the host. – AmithRc Apr 27 '18 at 14:37
  • In this case, you might end up installing an ssh daemon inside your containers. I think the base image doesn't have any ssh service running, so this is the reason that connections are refused. – tgogos Apr 27 '18 at 14:38
  • @tgogos, I do have sshd service running inside the container. I think I have mapped all the containers to the same SSH port. I did not expose the port during the run but I did modify their config file to allow port 22.I am using same port 22 for all the containers, Do you think its a problem? I do not think it should be a problem because each container will run in its own namespace. Thank you for your help. – AmithRc Apr 27 '18 at 14:42
  • Ok, try to provide an [mcve](https://stackoverflow.com/help/mcve) and don't forget to add the OS you are using, because there are networking limitations depending on the case. – tgogos Apr 27 '18 at 14:48
  • Are the containers connected to the default bridge network, or did you create a user defined network? Are you trying to access the containers by IP address or by container name? – takacsmark Apr 27 '18 at 15:17
  • @Mark The containers are on different network. container 1, container 3 has an isolated network and container 2 is acting as a router between container1 and container3. Will update the post soon once I get access to my system. – AmithRc Apr 27 '18 at 16:19
  • @Hi, All I was able to fix it by running the sshd binaries. ie /usr/sbin/sshd. Thank you for the help – AmithRc Apr 28 '18 at 22:13

1 Answers1

0

you have to bind an ip address using bridge or MacVlan network to do ssh

Nishad A
  • 103
  • 1
  • 12
  • 1
    A comment from the original questioner noted that they already have sshd running inside their containers. Neither "Install ... in a container" nor "service start" are really best practices in Docker: both ask for work to be lost when the container is deleted, and service/systemctl/... tend to not work because there's not an init daemon to handle them. – David Maze Jan 23 '19 at 11:50