Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

author Faisal Qureshi
email faisal.qureshi@ontariotechu.ca

Running an SSH server within a container

The Dockerfile shows how to run an SSH server within a container.

Building image

$ docker build -t ssh-image .

Run the container

$ docker run -d -P --name ssh-container ssh-image

If container already exists (or running), use docker rm to remove it as follows

$ docker rm --force ssh-container

Connecting using ssh

Use the following to see port mapping

$ docker port ssh-container

Next check the IP address of this container

$ docker inspect ssh-container

This returns a JSON string. Look for IPAddress under Network setting.

Now ssh into the container

$ ssh dockeruser@localhost -p <PORT>

PORT can be found using docker port command as shown above.