Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ssh autostart的dockerfile ssh僵尸进程_Docker_Ssh_Dockerfile_Zombie Process - Fatal编程技术网

ssh autostart的dockerfile ssh僵尸进程

ssh autostart的dockerfile ssh僵尸进程,docker,ssh,dockerfile,zombie-process,Docker,Ssh,Dockerfile,Zombie Process,您好,我在autostart sshd with container方面遇到了一些大问题 我的dockerfile: 我的入口点: 当我进入容器bash并键入: 服务ssh状态 我还得到了僵尸ssh过程:-| ps-ef | grep ssh 我是否在dockerfile中犯了一些错误???将此添加到您的入口点脚本中 service ssh restart && bash 更多信息 希望这有帮助。这是因为您使用Dockerfile末尾的USER node来启动sshd,我想

您好,我在autostart sshd with container方面遇到了一些大问题

我的dockerfile:

我的入口点:

当我进入容器bash并键入:

服务ssh状态

我还得到了僵尸ssh过程:-|

ps-ef | grep ssh


我是否在dockerfile中犯了一些错误???

将此添加到您的入口点脚本中

service ssh restart && bash
更多信息


希望这有帮助。

这是因为您使用Dockerfile末尾的
USER node
来启动sshd,我想您应该使用
node USER
来启动
npm

但是,建议的方法是使用
root
启动sshd并使用
节点
启动
npm
,您可以看到使用相同解决方案的著名项目
redis

然后,您需要进行下一个修复:

  • 删除Dockerfile末尾
    CMD
    之前的
    用户节点
  • 在dockerfile中删除
    运行chmod 0444/etc/ssh/*

    否则,下一步将报告导致sshd不工作的情况:

    “/etc/ssh/ssh\u host\u ecdsa\u key”的权限0444太开放

  • 删除
    运行echo'permitrotlogin=without password'>/etc/ssh/sshd_config
    ,使用next替换:

    RUN echo 'PermitRootLogin=yes' >> /etc/ssh/sshd_config
    
  • 在Dockerfile中添加
    运行apt get install-y gosu
    ,以安装gosu,该gosu稍后将在
    entrypoint.sh中使用

  • entrypoint.sh
    中,将
    exec“$@”
    更改为下一步:

    exec gosu node "$@"
    
    这将确保
    npm start
    仍然与用户节点一起运行


  • 然后,您可以看到,当启动容器时,sshd工作,如果需要,您可以使用
    service ssh stop&&service ssh start
    重新启动服务,但是由于容器现在运行良好,sshd,我想您不必再使用它了。

    不幸的是,它不适用于:
    服务ssh restart&&bash
    您可以将Dockerfile作为文本包含在问题本身中,而不是链接后面吗?噢,拜托;)那只是个垃圾桶
    RUN echo 'PermitRootLogin=yes' >> /etc/ssh/sshd_config
    
    exec gosu node "$@"