Docker create containers and mirrors that support SSH services

Source: Internet
Author: User
Tags docker run

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>

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.