CoreOS creating an Ubuntu base image with a key login

Source: Internet
Author: User
Tags docker run

Tag: Generate ROR port size ROM apt-get one author ISP

Download the official image
[Email protected] ~ $ docker Pull Ubuntu:14.04#假设官方下载较慢, the standard image can be downloaded to www.dockerpool.com[Email protected] ~ $ docker Pull dl.dockerpool.com: the/ubuntu:14.04[Email protected] ~ $ docker Tag dl.dockerpool.com: the/ubuntu:14.04Ubuntu:14.04[Email protected] ~ $ docker imagesrepository TAG IMAGE ID CREATED VIRTUAL SIZEdl.dockerpool.com: the/ubuntu14.04               1357F421be383Days ago192.7Mbubuntu14.04               1357F421be383Days ago192.7MB
Create a Dockerfile directory
[email protected] ~ $ mkdir base[email protected] ~ $ cd base[email protected] ~/base $~ $ ssh-keygen#生成訪问密钥[email protected] ~/base $ cat ~/.ssh/id_rsa.pub >authorized_keys
Dockerfile content:
#设置母镜像FROM ubuntu:14.04# provides information for some authors maintainer [email protected] #以下開始执行命令, here to change the source of Ubuntu for domestic 163 source run echo "Deb http ://mirrors.163.com/ubuntu/trusty main restricted Universe Multiverse ">/etc/apt/sources.listrun echo" deb/HTTP Mirrors.163.com/ubuntu/trusty-security main restricted universe multiverse ">>/etc/apt/sources.listrun echo" Deb Http://mirrors.163.com/ubuntu/trusty-updates main restricted universe multiverse ">>/etc/apt/ Sources.listrun echo "Deb http://mirrors.163.com/ubuntu/trusty-proposed main restricted universe multiverse" >>/ Etc/apt/sources.listrun echo "Deb Http://mirrors.163.com/ubuntu/trusty-backports main restricted universe multiverse" >>/etc/apt/sources.listrun apt-get updaterun apt-get upgrade-y# install ssh and supervisorrun apt-get install-y openssh-se RVer supervisorrun mkdir-p/var/run/sshdrun mkdir-p/var/log/supervisorrun mkdir-p/root/.ssh# cancel Pam limit run Sed-ri ' s/se Ssion required pam_loginuid.so/#session required PAm_loginuid.so/g '/etc/pam.d/sshd# Copy the configuration file to the corresponding location copy supervisord.conf/etc/supervisor/conf.d/supervisord.confcopy authorized_keys/root/.ssh/authorized_keys# Open port Expose 22CMD ["/usr/bin/supervisord"]
To create a supervisor.conf file:
[email protected] ~/base $ vi supervisord.conf#文件内容例如以下[supervisord]nodaemon=true[program:sshd]command=/usr/sbin/sshd -D

Verify the contents of the catalog

[email protected] ~/base $ lsDockerfile authorized_keys supervisord.conf[email protected] ~/base $ pwd/home/core/base
Create an image method
[email protected] ~/base $ docker build -t base/163 .
Start Container command
[email protected] ~/base $ docker run -p 100:22 -d base/163
Using a key to log in to a container
[email protected] ~/base $ ssh [email protected]127.0 . 0.1 -P 100  
   

CoreOS Create an Ubuntu base image using a key login

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.