在 docker 中无法通过 ssh 连接到 corda 节点

Can't connect to corda node via ssh in docker

当尝试通过 ssh 连接到 运行 corda 节点时,连接卡住并因超时而关闭。也许有人可以帮忙?看起来 docker 有一些问题,因为节点工作正常,只是无法通过 ssh 连接到它。

user@host:~$ ssh -v localhost -p 2222 -l users
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 2222.
debug1: connect to address 127.0.0.1 port 2222: Connection timed out
ssh: connect to host localhost port 2222: Connection timed out

Corda 节点 运行 被 docker 堆叠在 swarm 中。

user@host:~$ docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                      PORTS
umifcjj1qutf        stack_users    replicated          1/1                 repository/node:latest   *:2222->2222/tcp, *:10006->10201/tcp

服务定义。

// docker-stack.yml
services:
    users:
        image: ${DOCKER_REGISTRY}/node:latest
        volumes:
            - users-persistance:/opt/corda/persistance:rw
        configs:
            -   source: users_config
                target: /etc/corda/node.conf
            -   source: users_certificate_nodekeystore
                target: /opt/corda/certificates/nodekeystore.jks
            -   source: users_certificate_sslkeystore
                target: /opt/corda/certificates/sslkeystore.jks
            -   source: users_certificate_truststore
                target: /opt/corda/certificates/truststore.jks
            -   source: users_add_node_info_1
                target: /opt/corda/additional-node-infos/nodeInfo-71FB94D0663EEB32054F04AA0F0554EA8AA2CA684CA9A75D2689F854BAC7C814
            -   source: users_add_node_info_2
                target: /opt/corda/additional-node-infos/nodeInfo-777DA369F066FE34BEDE3E6334A1006A4026A02DD76AFA798204BD015C9965DE
            -   source: users_network_parameters
                target: /opt/corda/network-parameters
        ports:
            - 10006:10201
            - 2222:2222

请注意,一切正常,我的意思是此节点中的事务 运行 正常,但我不能只连接到该节点。

有趣的是,当 运行 使用 docker-compose 的节点工作正常时,我可以连接到该节点。

docker-compose.yml定义

users:
    build:
      context: ./blockchain/node
      target: api_platform_node_development
    image: ${DOCKER_REGISTRY}/node:latest
    volumes:
      - ./blockchain/build/nodes/Users/node.conf:/etc/corda/node.conf
      - ./blockchain/build/nodes/Users/certificates:/opt/corda/certificates
      - ./blockchain/build/nodes/Users/logs:/opt/corda/logs
      - ./blockchain/build/nodes/Users/persistence:/opt/corda/persistence
      - ./blockchain/build/nodes/Users/cordapps:/opt/corda/cordapps
      - ./blockchain/build/nodes/Users/network-parameters:/opt/corda/network-parameters
      - ./blockchain/build/nodes/Users/additional-node-infos:/opt/corda/additional-node-infos
      - ./blockchain/build/nodes/Users/drivers:/opt/corda/drivers
    ports:
      - 10006:10201
      - 2222:2222

Docker 版本 19.03.12,内部版本 48a66213fe

docker-compose version 1.21.2, build a133471

docker-compose.yml 版本:'3.4'

UPD: node.conf

dataSourceProperties {
    dataSource {
        url="jdbc:h2:file:./persistence/persistence;DB_CLOSE_ON_EXIT=FALSE;WRITE_DELAY=0;LOCK_TIMEOUT=10000"
    }
}
detectPublicIp=false
devMode=false
myLegalName="O=Users,L=London,C=GB"
p2pAddress="users:10200"
rpcSettings {
    address="0.0.0.0:10201"
    adminAddress="0.0.0.0:10202"
}
security {
    authService {
        dataSource {
            type=INMEMORY
            users=[
                {
                    password=password
                    permissions=[
                        ALL
                    ]
                    user=users
                }
            ]
        }
    }
}
sshd {
    port=2222
}

UPD 2.节点Docker文件 我正在为节点

使用标准 corda/corda-zulu-java1.8-4.4 docker 图像
FROM corda/corda-zulu-java1.8-4.4 AS api_platform_node_development

FROM corda/corda-zulu-java1.8-4.4 AS api_platform_node_production

COPY --from=repository/blockchain_build:latest /usr/blockchain/src/build/nodes/Users/cordapps /opt/corda/cordapps

希望对其他人有所帮助。问题实际上是 docker 堆栈行为,默认情况下它不会在外部发布端口,它们仅在 swarm 内可用,因此如果你想让它们在 swarm 外可用,你需要另外 运行

docker service update stack_users --publish-add 2222:2222