拉取almalinux

docker pull almalinux:almalinux:9

编写Dockerfile1

FROM almalinux:9
MAINTAINER szktor

RUN yum install -y openssh-server sudo unzip
RUN sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
RUN yum  install -y openssh-clients

RUN echo "root:root" | chpasswd
RUN echo "root   ALL=(ALL)       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 mkdir /var/run/sshd
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

运行Dockerfile1

docker build -f Dockerfile1 -t 'yz/almalinux-ssh' .
注意末尾有 点

更多推荐