I am currently experimenting with setting up the IPFS cluster locally using the docker-compose file mentioned here. This is recommended file in the official IPFS cluster documentation here.
The issue I am facing is, I am able to upload/pin data, but just on one node, i.e cluster0/ipfs0. when i do, peers ls, it shows:
It works for me when running the docker-compose file “as is” with docker-compse up.
It must indeed be an mDNS issue (probably specific to MacOS). I’m afraid you would have to investigate whether multicast is supported in MacOS for docker (perhaps there’s a way to enable it).
I tried running the same on the intel based mac, it runs perfectly fine. Is there a way to configure the docker compose to manually discover the peers? may be by setting peer set file configuration?
I found a solution for M1 macs, who do not able to discovers the peers. Try to manually connect clusters with each other writing a small script.
the basic idea is if you are having 3 peers, cluster0, cluster1, cluster2. Run and expose the cluster1. bootstrap the cluster1 and cluster2 to connect to cluster0. below is a sample docker-compose file.
version: '3.4'
services:
ipfs0:
container_name: ipfs0
image: ipfs/go-ipfs:latest
# ports:
# - "4001:4001" # ipfs swarm - expose if needed/wanted
# - "5001:5001" # ipfs api - expose if needed/wanted
# - "8080:8080" # ipfs gateway - expose if needed/wanted
volumes:
- ./compose/ipfs0:/data/ipfs
cluster0:
container_name: cluster0
image: ipfs/ipfs-cluster:latest
depends_on:
- ipfs0
environment:
CLUSTER_PEERNAME: cluster0
CLUSTER_SECRET: "" # From shell variable if set
CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs0/tcp/5001
CLUSTER_CRDT_TRUSTEDPEERS: '*' # Trust all peers in Cluster
CLUSTER_RESTAPI_HTTPLISTENMULTIADDRESS: /ip4/0.0.0.0/tcp/9094 # Expose API
CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
ports:
# Open API port (allows ipfs-cluster-ctl usage on host)
- "127.0.0.1:9094:9094"
# The cluster swarm port would need to be exposed if this container
# was to connect to cluster peers on other hosts.
# But this is just a testing cluster.
# - "9095:9095" # Cluster IPFS Proxy endpoint
# - "9096:9096" # Cluster swarm endpoint
volumes:
- ./compose/cluster0:/data/ipfs-cluster
ipfs1:
container_name: ipfs1
image: ipfs/go-ipfs:latest
volumes:
- ./compose/ipfs1:/data/ipfs
cluster1:
container_name: cluster1
image: ipfs/ipfs-cluster:latest
depends_on:
- ipfs1
environment:
CLUSTER_PEERNAME: cluster1
CLUSTER_SECRET: ""
CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs1/tcp/5001
CLUSTER_CRDT_TRUSTEDPEERS: '*'
CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
volumes:
- ./compose/cluster1:/data/ipfs-cluster
entrypoint:
- "/sbin/tini"
- "--"
command: >-
sh -c '
cmd="daemon"
if [ ! -d /data/ipfs-cluster/badger ]; then
while ! ipfs-cluster-ctl --host /dns4/cluster0/tcp/9094 id; do
sleep 1
done
pid=`ipfs-cluster-ctl --host /dns4/cluster0/tcp/9094 id | grep -o -E "^(\w+)"`
sleep 10
cmd="daemon --bootstrap /dns4/cluster0/tcp/9096/ipfs/$$pid"
fi
exec /usr/local/bin/entrypoint.sh $$cmd
'
ipfs2:
container_name: ipfs2
image: ipfs/go-ipfs:latest
volumes:
- ./compose/ipfs2:/data/ipfs
cluster2:
container_name: cluster2
image: ipfs/ipfs-cluster:latest
depends_on:
- cluster0
- ipfs2
environment:
CLUSTER_PEERNAME: cluster2
CLUSTER_SECRET: ""
CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs2/tcp/5001
CLUSTER_CRDT_TRUSTEDPEERS: '*'
CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
volumes:
- ./compose/cluster2:/data/ipfs-cluster
entrypoint:
- "/sbin/tini"
- "--"
command: >-
sh -c '
cmd="daemon"
if [ ! -d /data/ipfs-cluster/badger ]; then
while ! ipfs-cluster-ctl --host /dns4/cluster0/tcp/9094 id; do
sleep 1
done
pid=`ipfs-cluster-ctl --host /dns4/cluster0/tcp/9094 id | grep -o -E "^(\w+)"`
sleep 10
cmd="daemon --bootstrap /dns4/cluster0/tcp/9096/ipfs/$$pid"
fi
exec /usr/local/bin/entrypoint.sh $$cmd
'