原文地址html
FROM registry.aliyuncs.com/acs-sample/centos:6 MAINTAINER xuqh "xqh_163@163.com" RUN yum install -y openssh-server RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key RUN echo 'root:TopDocker' |chpasswd RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config EXPOSE 22 EXPOSE 80 CMD ["/usr/sbin/sshd", "-D"]
docker build -t aliyun/centos-sshd:6 .
docker
[root@iZ23g3sxtunZ dockerfile]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE aliyun/centos-sshd 6 a8eea9913432 17 minutes ago 277.5 MB registry.aliyuncs.com/acs-sample/centos 6 63b04d6634cc 4 weeks ago 190.6 MB
docker run -d -p 10022:22 -p 10080:80 --name centos aliyun/centos-sshd:6
centos
[root@iZ23g3sxtunZ dockerfile]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES e188fc592756 aliyun/centos-sshd:6 "/usr/sbin/sshd -D" 19 minutes ago Up 19 minutes 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp centos
注:能夠用netstat -lntp查看端口信息ssh
ssh root@192.168.x.x -p 10022
tcp
rm -rf ~/.ssh/known_hosts
測試
Hubui