5-Docker实例-centos-ssh(1)

基于Docker制作centos7镜像,镜像支持开启sshd服务。

1.制作ssh Dockerfile,并保存

命令:

vim Dockerfile

[root@centos79 ~]# cat Dockerfile
FROM ansible/centos7-ansible
MAINTAINER ztj
RUN rpm --rebuilddb;yum install make wget tar gzip passwd openssh-server gcc -y
ENV REPOS_URL http://mirrors.163.com/.help/CentOS7-Base-163.repo
RUN rm -rf /etc/yum.repos.d/*;wget -P /etc/yum.repos.d/ ${REPOS_URL}
RUN yes|ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ''
RUN yes|ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
RUN yes|ssh-keygen -q -t ed25519 -f /etc/ssh/ssh_host_ed25519 -N ''
RUN echo 'root' | passwd --stdin root
EXPOSE 22
CMD /usr/sbin/sshd -D 
[root@centos79 ~]# pwd
/root
[root@centos79 ~]# ls -l Dockerfile
-rw-r--r-- 1 root root 537 11月 28 17:21 Dockerfile
[root@centos79 ~]# 

2.基于Dockerfile创建镜像

命令:

docker build -f Dockerfile -t centos-ssh

你可能感兴趣的:(docker,docker,centos,ssh)