Psychz - Raviteja
Votes: 0Posted On: Dec 21, 2017 02:37:28
To SSH into the desired container, you must first install an SSH server in the image you wish to ssh-into.
A base image can be used for all your container with the ssh server installed. Once you do this you only have to run each container mapping the ssh port (default 22) to one to the host's ports (Remote Server in your image), using -p :
For example
docker run -p 52022:22 container1
docker run -p 53022:22 container2
Then, if ports 52022 and 53022 of host's are accessible from outside, you can directly ssh to the containers using the IP of the host (Remote Server) specifying the port in ssh with -p . I.e.:
ssh -p 52022 user@172.158.x.x --> SSH to container1
ssh -p 53022 user@172.158.x.x --> SSH to container2