localhost:错误:ssh:连接到主机 localhost 端口 22:地址不可用

localhost:错误:ssh:连接到主机 localhost 端口 22:地址不可用

我是 docker 新手,想设置 Hadoop 容器,首先为它创建 ssh-server 容器,以便于调试,因为我的第一个容器运行良好,可以登录

ssh 本地主机

在容器内无需任何密码。

ssh-容器: https://github.com/nitesh-kumar-sharma/hands-dirty-docker/blob/master/hadoop/Dockerfile

docker build -t ssh-local .
docker run -d ssh-local

建立成功!!

Hadoop容器: https://github.com/nitesh-kumar-sharma/hands-dirty-docker/blob/master/ssh/Dockerfile

当我运行第二个 Hadoop 容器时,它说

ERROR: ssh: connect to host localhost port 22: Address not available

请在存储库中查找所有相关文件。 https://github.com/nitesh-kumar-sharma/hands-dirty-docker/blob/master/

Hadoop容器日志:

This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
Starting namenodes on [localhost]
localhost: ssh: connect to host localhost port 22: Address not available
localhost: ssh: connect to host localhost port 22: Address not available
Starting secondary namenodes [0.0.0.0]
0.0.0.0: ssh: connect to host 0.0.0.0 port 22: Connection refused
starting yarn daemons
BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.

Usage: chown [-RhLHPcvf]... USER[:[GRP]] FILE...

Change the owner and/or group of each FILE to USER and/or GRP

        -R      Recurse
        -h      Affect symlinks instead of symlink targets
        -L      Traverse all symlinks to directories
        -H      Traverse symlinks on command line only
        -P      Don't traverse symlinks (default)
        -c      List changed files
        -v      List all files
        -f      Hide errors
starting resourcemanager, logging to /usr/local/hadoop/logs/yarn--resourcemanager-40777cdc0820.out
localhost: ssh: connect to host localhost port 22: Address not available

答案1

实际上,当 docker 尝试运行这个 docker 文件时,它没有打开 SSL 端口,所以我遇到了这个问题,但我很困惑,因为我已经在 ENTRYPOINT 中添加了运行命令。

因此我在 bootstrap.sh 中添加了一些小脚本来检查 ssl 是否未启动,然后先启动服务,然后尝试启动 Hadoop 服务。

# Run ssh on logging, only if not running yet
ACTIVE=$(pgrep -f /usr/sbin/sshd)
if [ ! "$ACTIVE" ]; then
    echo "starting sshd....";

    echo "successfully started PID = $(pgrep -f /usr/sbin/sshd)";
else
    echo "ssh service already started PID=$ACTIVE"
fi

相关内容