【发布时间】:2014-10-04 20:18:37
【问题描述】:
我使用 Docker 在本地构建了一个 Docker 映像,它运行 SSH 服务器 + 一些其他服务。 Dockerfile 是内部的,所以我不能在这里发布。但我做的基本事情是:
RUN apt-get install -q -y openssh-server openssh-client
RUN cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults
RUN chmod a-w /etc/ssh/sshd_config.factory-defaults
RUN mkdir /var/run/sshd
RUN echo 'root:changeme' |chpasswd
ADD ./bootstrap.sh /root/bootstrap.sh
ENTRYPOINT ["sh", "/root/bootstrap.sh"]
在 bootstrap.sh 内部:
...
echo "Starting SSH service..."
/usr/sbin/sshd -D > /dev/null 2>&1 &
ps -A | grep sshd
...
...到目前为止它仍然有效。 我可以从主机连接到 SSH 服务器(在 Ubuntu 容器内运行)。
到目前为止,一切都很好。现在我已将图像上传到 Dockerhub 并在 tutum.co 上运行它。
现在问题:SSH 服务器启动,但我无法连接到它。甚至在容器的局部内部。顺便说一句,我有一个浏览器外壳,所以我仍然能够执行命令。
我在容器内执行:
ssh root@localhost -v
OpenSSH_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debia
n-5ubuntu1.4
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: SSH2_MSG_KEXINIT sent
Read from socket failed: Connection reset by peer
【问题讨论】: