Docker creates containers and mirrors that support SSH services

Source: Internet
Author: User
Tags docker run

Docker creates containers and mirrors that support SSH services

    1. Use CentOS as a container here, so first download CentOS images

      Sudo docker pull CentOS

    2. Download and run a CentOS container, Here I use CENTOS6 as my Test Container

      Sudo docker run--name=centos-ssh-i-T centos:centos6/bin/bash

    3. Install the Openssh-server service package

      Yum install openssh-server

    4. Edit sshd configuration file/etc/ssh/sshd_config, Set the Usepam parameter to "no"

    5. Start the sshd service

      /etc/init.d/sshd start

    6. Add test user admin, password admin

      Useradd Admin

      Echo ' admin:admin ' | chpasswd

    7. In order for the newly added user to run the sudo command, it is necessary to install the sudo package and add the admin to sudoers

      Yum install sudo <--install sudo package

      Visudo < ---Edit sudoers, add the following line to the file

      Admin all= (All) all

    8. Test, after the above work, use ifconfig to view the container's IP, or use the sudo docker Inspect "View, then you can access the newly created Docker container via SSH [email protected]<ip> on the host machine.

    9. If you want to make the container that supports the SSH service as a Docker image, first exit the container, and then use the following command to create the

      sudo docker commit <container id> <image name>

Docker creates containers and mirrors that support SSH services

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.