简体   繁体   中英

How do I ssh from one docker container to another docker container?

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 在此输入图像描述

你必须使用网桥或MacVlan网络绑定一个IP地址来做ssh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM