In order for you to ssh into the second container on port 22, you would need to get the host daemon ec2 vm ssh.
One way is to change the ssh port of the host machine by adding the entry in the / etc / ssh / sshd _config file to about 3022. Now you can use -p 22:22 when you start your docker container (s) and you can ssh between them . However, the ssh`ing instance of ec2 is at 3022.
If you want host-vms to also have ssh enabled on port 22, then you will need to create a second virtual ethernet interface. This is easy to do if you can set static IPs. something like ifconfig eth0:0 192.168.1.11 up . However, in ec2 this will not be possible since you have DHCP based IP addresses.
The third way is to configure your .ssh / config file to map to a non-standard port. This does not allow you to send ssh over port 22, but at least you do not need to know about the non-standard port. Here is a tutorial , and related parts below.
# contents of $HOME/.ssh/config Host other_docker HostName ec2-host-name-of-other-docker.com Port 22000 User some_user
Now you can just do ssh other_docker
Usman ismail
source share