CoreOS creating an Ubuntu base image with a key login

Source: Internet
Author: User
Tags docker run

Download the official image
[Email protected] ~ $ docker Pull Ubuntu:14.04#如果官方下载较慢, the standard image can be downloaded to[Email protected] ~ $ docker Pull the/ubuntu:14.04[Email protected] ~ $ docker Tag the/ubuntu:14.04Ubuntu:14.04[Email protected] ~ $ docker imagesrepository TAG IMAGE ID CREATED VIRTUAL the/ubuntu14.04               1357F421be383Days ago192.7Mbubuntu14.04               1357F421be383Days ago192.7MB
Create a Dockerfile folder
[email protected] ~ $ mkdir base[email protected] ~ $ cd base[email protected] ~/base $~ $ ssh-keygen#生成访问密钥[email protected] ~/base $ cat ~/.ssh/ >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 :// main restricted Universe Multiverse ">/etc/apt/sources.listrun echo" deb/HTTP main restricted universe multiverse ">>/etc/apt/sources.listrun echo" Deb Http:// main restricted universe multiverse ">>/etc/apt/ Sources.listrun echo "Deb main restricted universe multiverse" >>/ Etc/apt/sources.listrun echo "Deb Http:// 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 required '/etc/pam.d/sshd# Copy the configuration file to the appropriate 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 folder

[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: 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.