title: How can I set up hyperledger fabric with multiple hosts using Docker?
body: <p>I work on the Hyperledger Fabric v1.0 and would like to make the <a href="http://hyperledger-fabric.readthedocs.io/en/latest/asset_setup.html" rel="noreferrer">Getting Setup</a> work on multiple hosts. For now, 2 would be great.</p>
  
  <p>Here is what I want to do: </p>
  
  <ol>
  <li><strong>Host1</strong>: start an orderer and 2 peers</li>
  <li><strong>Host2</strong>: start 1 peer</li>
  <li><strong>Host2</strong>: A client creates a channel (using the channel_test.sh updated with the good hosts IP) and join all the 3 peers</li>
  <li><strong>Host1</strong>: Call de deploy.js of the given example to deploy the chaincode</li>
  </ol>
  
  <p>I have a problem on the 3rd step. I think the channel creation works but on my peers log I have the same warnings on the 3 peers: </p>
  
  <pre><code>Remote endpoint claims to be a different peer, expected [host1 IP:8051] but got [172.17.0.4:7051]
  Failed obtaining connection for 172.31.9.126:8051, PKIid:[49 55 50 ...] reason: Authentication failure
  </code></pre>
  
  <p>It looks like they can't communicate with each other. <strong>Any idea where the problem is?</strong> </p>
  
  <p>I still tried my step 4 but I can't deploy it unless I remove the host2: peer1 from the config.json. And even then, I can only query from the host1: peer0, not the host1: peer2.</p>
  
  <p>Here are the commands I use to set up my network:</p>
  
  <p><strong>Host1: Orderer</strong></p>
  
  <pre><code>docker run --rm -it --name orderer -p 8050:7050 
  -e ORDERER_GENERAL_LEDGERTYPE=ram 
  -e ORDERER_GENERAL_BATCHTIMEOUT=10s 
  -e ORDERER_GENERAL_BATCHSIZE_MAXMESSAGECOUNT=10 
  -e ORDERER_GENERAL_MAXWINDOWSIZE=1000 
  -e ORDERER_GENERAL_ORDERERTYPE=solo 
  -e ORDERER_GENERAL_LOGLEVEL=debug 
  -e ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 
  -e ORDERER_GENERAL_LISTENPORT=7050 
  -e ORDERER_RAMLEDGER_HISTORY_SIZE=100 
  sfhackfest22017/fabric-orderer:x86_64-0.7.0-snapshot-c7b3fe0 orderer
  </code></pre>
  
  <p><strong>Host1: Peer0</strong></p>
  
  <pre><code>docker run --rm -it --name peer0 -p 8051:7051 -p 8053:7053
  -v /var/run/:/host/var/run/ -v $BASE_DIR/tmp/peer0:/etc/hyperledger/fabric/msp/sampleconfig 
  -e CORE_PEER_ADDRESSAUTODETECT=true 
  -e CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock 
  -e CORE_LOGGING_LEVEL=DEBUG 
  -e CORE_PEER_NETWORKID=peer0 
  -e CORE_NEXT=true 
  -e CORE_PEER_ENDORSER_ENABLED=true 
  -e CORE_PEER_ID=peer0 
  -e CORE_PEER_PROFILE_ENABLED=true 
  -e CORE_PEER_COMMITTER_LEDGER_ORDERER=$ORDERER_IP:7050 
  -e CORE_PEER_GOSSIP_ORGLEADER=true 
  -e CORE_PEER_GOSSIP_IGNORESECURITY=true 
  sfhackfest22017/fabric-peer:x86_64-0.7.0-snapshot-c7b3fe0 peer node start --peer-defaultchain=false
  </code></pre>
  
  <p><strong>Host1: Peer2</strong></p>
  
  <pre><code>docker run --rm -it --name peer2 -p 8055:7051 -p 8057:7053 
  -v /var/run/:/host/var/run/ -v $BASE_DIR/tmp/peer0:/etc/hyperledger/fabric/msp/sampleconfig
  -e CORE_PEER_ID=peer2 
  [Other parameters are the same as Peer0]
  sfhackfest22017/fabric-peer:x86_64-0.7.0-snapshot-c7b3fe0 peer node start --peer-defaultchain=false
  </code></pre>
  
  <p><strong>Host2: Peer1</strong></p>
  
  <pre><code>docker run --rm -it --name peer1 -p 8051:7051 
  -v /var/run/:/host/var/run/ -v $BASE_DIR/tmp/peer0:/etc/hyperledger/fabric/msp/sampleconfig
  -e CORE_PEER_ID=peer1 
  [Other parameters are the same as Peer0]
  sfhackfest22017/fabric-peer:x86_64-0.7.0-snapshot-c7b3fe0 peer node start --peer-defaultchain=false
  </code></pre>
  
  <p><strong>Host2: Cli</strong></p>
  
  <pre><code>docker run --rm -it --name cli
      -v /var/run/:/host/var/run/ -v $BASE_DIR/tmp/peer3:/etc/hyperledger/fabric/msp/sampleconfig -v $BASE_DIR/src/github.com/example_cc/example_cc.go:/opt/gopath/src/github.com/hyperledger/fabric/examples/example_cc.go -v $BASE_DIR/channel_test.sh:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel_test.sh
      --workdir /opt/gopath/src/github.com/hyperledger/fabric/peer  
      -e GOPATH=/opt/gopath 
      -e CORE_PEER_ADDRESSAUTODETECT=true
      -e CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock 
      -e CORE_LOGGING_LEVEL=DEBUG 
      -e CORE_NEXT=true 
      -e CORE_PEER_ID=cli 
      -e CORE_PEER_ENDORSER_ENABLED=true 
      -e CORE_PEER_COMMITTER_LEDGER_ORDERER=$ORDERER_IP:8050 
      -e CORE_PEER_ADDRESS=$PEER0_IP:8051 
      sfhackfest22017/fabric-peer:x86_64-0.7.0-snapshot-c7b3fe0 ./channel_test.sh
  </code></pre>
  
  <p>If you need more information feel free to ask.</p>
  
  <p><em>Note: I'm not very familiar with docker, any improvement/advice on how I use it is welcome :)</em></p>