附带ssh的alpine镜像
# 指定创建的基础镜像
FROM alpine:3
# 作者描述信息
MAINTAINER alpine_sshd_service
# 替换阿里源,安装openssh,并修改配置文件和生成key,并且同步时间。
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
&& apk update \
&& apk add --no-cache openssh tzdata \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config \
&& ssh-keygen -t dsa -P "" -f /etc/ssh/ssh_host_dsa_key \
&& ssh-keygen -t rsa -P "" -f /etc/ssh/ssh_host_rsa_key \
&& ssh-keygen -t ecdsa -P "" -f /etc/ssh/ssh_host_ecdsa_key \
&& ssh-keygen -t ed25519 -P "" -f /etc/ssh/ssh_host_ed25519_key \
&& echo "root:123." | chpasswd
# 开放22端口
EXPOSE 22
# 容器启动时执行ssh启动命令
CMD ["/usr/sbin/sshd", "-D"]
标签:&&,etc,host,ssh,key,镜像,alpine
From: https://www.cnblogs.com/srczhang/p/16965780.html