Search code examples
dockerhyperledger-fabricdocker-swarmdistributed-system

Docker Swarm Error Response


I'm trying to run the tutorial to use my chain code on multiple hosts.

After copying this (with PC 1's output of course):

docker swarm join — token SWMTKN-1–3as8cvf3yxk8e7zj98954jhjza3w75mngmxh543llgpo0c8k7z-61zyibtaqjjimkqj8p6t9lwgu 172.16.0.153:2377

from PC 1 to PC 2, I'm getting an error output like this:

Error response from daemon: rpc error: code = Unavailable desc = grpc: the connection is unavailable

I googled this problem, but haven't found a solution to solve my problem yet. Can anyone help?


Solution

  • The solution to your problem is initializing the swarm with the network IP of PC 1. If you're on a windows machine, use ipconfig; on Linux and MAC use ifconfig; to see the IP of the interface you're connected to the network with. Most probably, it would be something like 192.168....

    You can confirm whether this IP is reachable from PC 2 by pinging it from PC 2 using ping <PC 1 IP>. If it gives success response, you're good to go to the next step. Otherwise, you used a wrong IP. Try some other interface's IP.

    After finding the IP, initialize the swarm using the following commands. Use the IP found above in the second command.

    docker swarm leave --force

    docker swarm init --advertise-addr <IP address of PC 1>

    Use the output of the last command in PC 2 and it should get connected to the swarm as a worker with PC 1 as the manager. Before joining swarm on PC 2, execute docker swarm leave --force just to be safe.