wget http://ftp.sjtu.edu.cn/fedora/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm
rpm -ivh epel-release-7-0.2.noarch.rpm
yum install docker-io --enablerepo=epel
service docker start
下载官方centos镜像
docker pull centos
进入实例配置ssh服务
bash-4.2#yum -y install openssh-server
bash-4.2#mkdir /var/run/sshd
bash-4.2#service sshd start
bash-4.2#passwd
bash-4.2#exit
保存更改到镜像
docker ps -l
docker commit 51774a81beb3 centos:centos6
后台运行实例
docker run -d -p 22 centos:centos6 /usr/sbin/sshd -D
系统会自动随机端口映射到22端口,可用于远程连接