This is image of Ubuntu 16.04 with ssh server installed
350
This is docker image of Ubuntu with ssh server enabled. You can run the docker container and connect to it using SSH (private key).
Download or clone the UbuntuWithSSH-Docker project from github (https://github.com/devbkhadka/UbuntuWithSSH-Docker)
Open you terminal and cd to root of UbuntuWithSSH-Docker project
The project also contains rsa private and public key. Public key will be copied into docker image and private key will be used to ssh-into container latter. If you already have privte and public key you can replace them but name should be "id_rsa" and "id_rsa.pub".
Change permission of "id_rsa" file to readonly by owner only with following command
chmod 0400 id_rsa
Build docker image with following command. Don't miss the "." at the end
docker build -t ubuntuwithsshexample .
After docker image has been created, run following command to run docker container. Option "-d" says run in background (demon mode) and "-p 2222:22" maps hosts port 2222 to containers port 22
docker run -d -p 2222:22 ubuntuwithsshexample
Now you can ssh-into the running container with following command
ssh -p 2222 -i id_rsa root@localhost
Find container id with following command
docker ps
Copy container id and run following commands with the container id
docker stop [container id]
docker rm [container id]
Content type
Image
Digest
Size
90.2 MB
Last updated
about 9 years ago
docker pull devkhadka/ubuntuwithssh:1.0.2