想在容器内使用 ssh 不知道如何打包镜像,有没有佬可以解答一下疑问,容器内部的权限很也迷惑(不了解),有没有人可以解惑?
你可以问问gpt
试过了 run 不起来
Dockerfile
FROM centos:centos7.6.1810
RUN yum install -y vim openssh-* git bash-completion net-tools python3 initscripts\
&& yum clean all
COPY startssh.sh /startssh.sh
CMD /startssh.sh
startssh.sh
#!/bin/bash
echo "sshd starting..."
if [ -z "$USER_PASSWORD" ]
then
USER_PASSWORD="linuxdo123"
fi
echo root:${USER_PASSWORD} |chpasswd
if [ ! -e /root/.ssh/id_rsa ]
then
ssh-keygen -t rsa -f /root/.ssh/id_rsa -C "" -N ""
fi
/etc/init.d/sshd start
echo "sshd successfully started"
while true; do who;sleep 3600; done
1 个赞
感谢 我一会去试一试