制作一个带有ssh的镜像
FROM centos:7 RUN yum install -y openssh-server openssh-clients sudo RUN sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config RUN useradd hadoop RUN echo "hadoop:hadoop" | chpasswd RUN echo "hadoop ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key RUN ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N "" # 启动sshd服务并且暴露22端口 RUN mkdir /var/run/sshd
##加上此内容则是Hadoop账号免密登陆,hadoop需要
RUN chmod -R 755 /etc/ssh/
##加上此内容则是Hadoop账号免密登陆,hadoop需要
RUN chmod +s /usr/sbin/sshd
##加上此内容则是Hadoop账号免密登陆,hadoop需要
USER hadoop
RUN ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
RUN cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
EXPOSE 22
ENTRYPOINT ["/usr/sbin/sshd","-D"]
docker build -t centos7-ssh:v1 .