Original link: Docker create containers and mirrors to support SSH services
1. The CentOS used here as a container, so first download the CentOS images
# sudo docker pull CentOS
2. After downloading run a CentOS container, here use CENTOS6 as my Test Container
# sudo docker run--name=centos-ssh-i-T Centos:centos6/bin/bash
3. Install Openssh-server Service Package
# yum Install Openssh-server
4. Edit the sshd profile/etc/ssh/sshd_config, and set the Usepam parameter to "no"
5. Start sshd Service
#/etc/init.d/sshd Start
6. Add test user admin, Password admin
# useradd Admin
# echo ' admin:admin ' | chpasswd
7. To enable the newly added user to run sudo command, you need to install the Sudo software package and add admin to sudoers
# yum Install sudo <--install sudo package
# visudo <--Edit sudoers, add the following line to file
admin all= (All)
8. Test, after the above work, use ifconfig to view the container's IP, or use the "sudo docker inspect" view, and then on the host machine through the SSH admin@<ip> to access the newly created Docker container.
9. If you want to have a good, SSH-enabled container as a Docker mirror, exit the container, and then use the following command to create the
# sudo docker commit <container id> <image name>