Docker on CentOS uses Dockerfile build container for SSH

Source: Internet
Author: User
Tags connection reset docker ps docker run

These days in learning Docker, the number of problems encountered in a year is not complete, the internet is mostly Ubuntu, Baidu or Google when the heart is very tired. Write documentation to help Docker enthusiasts who use CentOS.

Docker basic operations This is not covered here. Write Time: December 25, 2015 17:41:41

If you are ready to start learning, or if you are ready to use SSH to connect the container this function, please first toss yourself. Otherwise, you can't reach the goal of learning.

Ssh-p 32772 [email protected]read from socket failed:connection Reset by peer

See this error I guess most of the students are very irritable, congratulations, found this article

Here we go directly to Dockerfile

#syw/centos:ssh# #by: vfrom centos:centos6.6 maintainer syw "[email protected]" RUN yum-y install Openss H-server;yum clean allrun mkdir/var/run/sshdrun ssh-keygen-t rsa-f/etc/ssh/ssh_host_rsa_keyrun ssh-keygen-t dsa-f/E Tc/ssh/ssh_host_dsa_keyrun/bin/echo ' root:123456 ' |chpasswdrun/bin/sed-i ' s/.*session.*required.*pam_loginuid.so. */session Optional pam_loginuid.so/g '/etc/pam.d/sshdrun/bin/echo-e "lang=\" en_US. Utf-8\ "" >/etc/default/localexpose 22cmd/usr/sbin/sshd-d

Use build to package into image

Docker build-t Syw/centos6:ssh.

This is sometimes caused by network reasons, or for some other reason, the name of the packaged image is <none>, and if this error occurs, it means that the package image is wrong. (You can also note the Strin in the build process)

If successful, you will be prompted to pack successfully.

Successfully built 3EA906C5B3A9

Here we create a container to experiment with

Docker run-d-P--name endtest syw/centos6:ssh

In view container status, if no exit instructions successfully docker PS

If there is no continuous process in the container, the container exits. Here we see the container exposed 22 ports corresponding to the host's 32769

So let's check ssh to verify

Exit the command to not close the container for ctrl+p+q here's a way to record the KVM for ctrl+[.

If you have any questions, leave a message!

Docker on CentOS uses Dockerfile build container for SSH

Related Article

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.