IPFS Cluster peers not able to discover each other

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:

12D3KooWKpQhmnaJfMpkbnM9hc5MCHBPzcDLneSCTZir3KfzhEzv | cluster0 | Sees 0 other peers
  > Addresses:
    - /ip4/127.0.0.1/tcp/9096/p2p/12D3KooWKpQhmnaJfMpkbnM9hc5MCHBPzcDLneSCTZir3KfzhEzv
    - /ip4/172.31.0.6/tcp/9096/p2p/12D3KooWKpQhmnaJfMpkbnM9hc5MCHBPzcDLneSCTZir3KfzhEzv
  > IPFS: 12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY
    - /ip4/127.0.0.1/tcp/4001/p2p/12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY
    - /ip4/127.0.0.1/udp/4001/quic/p2p/12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY
    - /ip4/172.31.0.3/tcp/4001/p2p/12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY
    - /ip4/172.31.0.3/udp/4001/quic/p2p/12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY
    - /ip4/54.189.89.138/tcp/4001/p2p/12D3KooWNgxATDv46KseNrQZSQ1A1urKKMv9y8rrVGwmVEYdKuPi/p2p-circuit/p2p/12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY
    - /ip4/54.189.89.138/udp/4001/quic/p2p/12D3KooWNgxATDv46KseNrQZSQ1A1urKKMv9y8rrVGwmVEYdKuPi/p2p-circuit/p2p/12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY
    - /ip4/66.42.103.205/tcp/4001/p2p/12D3KooWRwEtLndMA7eALuKADnqchPDcDNwbhdhNiFLUkDmaJ9bw/p2p-circuit/p2p/12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY
    - /ip4/66.42.103.205/udp/4001/quic/p2p/12D3KooWRwEtLndMA7eALuKADnqchPDcDNwbhdhNiFLUkDmaJ9bw/p2p-circuit/p2p/12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY
    - /ip6/64:ff9b::36bd:598a/tcp/4001/p2p/12D3KooWNgxATDv46KseNrQZSQ1A1urKKMv9y8rrVGwmVEYdKuPi/p2p-circuit/p2p/12D3KooWQJKdmuErPxaobQMnWMdGPSKeBiJLJ9GYDGz8dgyLmpuY

As you can see, it is not able to detect other peers.

few notes:

  • I am setting up the secret correct. its all same across all cluster’s service.json file
  • I am able to ping the containers from each other, which mean containers can able to talk to each other.
  • I am using the exactly the same docker-compose file as it is mentioned in the doc.

I think the issue is with the mDNS, I am getting this error/log on all the three cluster:
mDNS could not be started: no supported interface

Please help me out to debug this. Thanks

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).

1 Like

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?

@hector

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
      '