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