I am trying to set up a 2 node IPFS on docker. My docker-compose file looks as follows
This gives following ERROR on starting.
yes, we are missing more detailed documentation about deploying with docker, particularly providing compose templates.
The existing docs do however point out that you need to run ipfs on the side. The error you are getting is related. Also, the ports you are defining are ipfs ports, not cluster. Cluster uses 9094, 9095 and 9096 by default (https://cluster.ipfs.io/documentation/security/).
I figured out how to run a multi-node IPFS cluster on docker environment.
The current ipfs/ipfs-cluster which is version 0.4.17 doesn’t run ipfs peer i.e. ipfs/go-ipfs in it. We need to run it separately.
So now in order to run a multi-node (2 node in this case) IPSF cluster in docker environment we need to run 2 IPFS peer container and 2 IPFS cluster container 1 corresponding to each peer.
So your docker-compose file will look as follows :
This will spin 2 peer IPFS cluster and we can store and retrieve file using any of the peer.
The catch here is we need to provide the IPFS_API to ipfs-cluster as environment variable so that the ipfs-cluster knows its corresponding peer. And for both the ipfs-cluster we need to have the same CLUSTER_SECRET.
You should be able to provide IPFS_API as /dns4/ipfs0/tcp/5001 (I think docker will let ipfs0 resolve to whatever IP was assigned to that container right?). In that case, you should not need to fix the IP addresses of the ipfs containers. I haven’t tested this with docker so it would be very cool if you can tell me if it works as expected. You can also so the same with the cluster addresses in the peerstore file: dns4/ipfs-cluster1/tcp/9094/ipfs/peerid.