I am trying to set up a 2 node IPFS on docker. My docker-compose file looks as follows
version: β3β
services:
peer-1:
image: ipfs/ipfs-cluster:latest
ports:
- 8080:8080
- 4001:4001
- 5001:5001
volumes:
- ./cluster/peer1/config:/data/ipfs-cluster
peer-2:
image: ipfs/ipfs-cluster:latest
ports:
- 8081:8080
- 4002:4001
- 5002:5001
volumes:
- ./cluster/peer2/config:/data/ipfs-cluster
This gives following ERROR on starting.
Whats going wrong with this?
Is there any documentation or tutorial about how to setup IPSF cluster on docker, step by step. Although this tells about deploying IPFS using docker, its misses on lot.
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/).
Also I cannot see it, but just in case: for your docker cluster to start correctly (with the given compose file) you will need the configuration files correctly set so that the cluster can start with a fixed peerset for the first time: https://cluster.ipfs.io/documentation/starting/#starting-multiple-peers-with-a-fixed-peerset . Otherwise, maybe the peers may run but maybe as two separate clusters of 1 peer.
Finally, there is a typo in your peer-2 image: ipfs/ipfs-cluster:latests should be latest.
We would be happy if you share your results, maybe we can use it to document the process for someone else.
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.