Docker: Create an image that supports SSH service!!!

Source: Internet
Author: User
Tags ssh port

Project background:

We are a cloud service provider, and we use Dockerfile to create an image that supports the SSH service to the user. Does that sound really cool? In fact, Docker is able to meet this demand!!! Everyone can be a cloud service Provider!!!!





Lab Environment:

VMware Workstation 11

Under the centos7.0 system

Server: ip:192.168.0.61

SECURECRT (SSH remote connection software)






Experimental process:

First, create our Active Directory

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7E/5D/wKiom1b9CsOjMa0gAAD16HLl2bk856.png "title=" Create the Active Directory. png "alt=" Wkiom1b9csojma0gaad16hll2bk856.png "/>

Second, generate a key pair on the host.

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7E/5D/wKiom1b9C6PSqMvxAAFc9zACTXs480.png "title=" Create the key. png "alt=" Wkiom1b9c6psqmvxaafc9zactxs480.png "/> Three, just remember to copy the public key to Authorized_keys.

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7E/59/wKioL1b9DIqROzU-AACCWQZwmNk724.png "title=" Authorized file generation. png "alt=" wkiol1b9diqrozu-aaccwqzwmnk724.png "/>z this step is important.

Four, the main dish comes! Write Dockerfile file!!!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7E/5D/wKiom1b9DRajoScpAAFTM1gbCRI154.png "title=" Create a dockerfile file. png "alt=" Wkiom1b9drajoscpaaftm1gbcri154.png "/> Five, run dockerfile, create mirror

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7E/5D/wKiom1b9DtrSIWtCAAGxts5r05o302.png "title=" Dockerfile execute. png "alt=" Wkiom1b9dtrsiwtcaagxts5r05o302.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7E/5D/wKiom1b9DzWSlbcIAAD9bXg1lgQ754.png "title=" Create our image with Dockerfile. png "alt=" Wkiom1b9dzwslbciaad9bxg1lgq754.png "/>

You can see that the display was created successfully and will give a mirror ID


Six, run the image, do a local port with the container SSH port to do a mapping.

Docker run-d-P 10521:22 sshd:dockerfile


Seven, view the image of the boot state we created.


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7E/59/wKioL1b9EEGSkpTWAAGNxAiRzQE816.png "title=" Port mapping. png "alt=" Wkiol1b9eegskptwaagnxairzqe816.png "/> You can see that local port 10521 is mapped to the port in the container. You can access the SSH service within the container by accessing local port 10521.


Eight, in the local SSH link to inside the container

SSH 192.168.0.51-p 10521

Just as we visit a standalone server. Isn't it cool!!!!?



Project summary: I used to think that the cloud service provider, the cloud service provider, feel very advanced, in fact, Docker can let you become a can provide a customized cloud service provider. Technology is very appealing. I hope we all have something to gain.




This article is from the "Make a few" blog, be sure to keep this source http://9399369.blog.51cto.com/9389369/1758958

Docker: Create an image that supports SSH service!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.