1,通过pipework的方式,设置了容器的ip,但是同一个宿主机下的容器之间可以相互ping通,但是ssh连不过去(就是到输完密码,立即断开);能够通过宿主机ssh到本机的容器中;也能够通过其他宿主机ssh连接到其他宿主机的容器;但是不同容器之间ssh都失败;
2,也用weave的方式试过,但是ssh到容器的ip,进入的却是宿主机;请道友们帮忙解答。

解决方案 »

  1.   

    你的docker容器ssh端口没有映射到宿主机吧,你开个端口映射到docker的22端口
      

  2.   

    应该是ssh和pam的设置问题
    在Dockerfile里加上
    RUN ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key; \
        ssh-keygen -q -N "" -t ecdsa -f /etc/ssh/ssh_host_ecdsa_hey; \
        ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_ed25519_key; \
        sed -i "s/^\s*\(session\s\+required\s\+pam_loginuid\.so\)/#\1/g" /etc/pam.d/sshd; \
        sed -i "/^\s*#\s*PermitRootLogin.*/aPermitRootLogin yes" /etc/ssh/sshd_config; \
        echo 'root:admin123' | chpasswd
    再重新build镜像