yeasy / docker-blockchain-explorer

Docker image of the blockchain-explorer
18 stars 8 forks source link

docker run -d yeasy/blockchain-explorer not work #6

Closed cyberhorse208 closed 6 years ago

cyberhorse208 commented 6 years ago

i started a fabric network, like this:

xx@ubuntu:~/projects/data/hyperledger/fabric/docker-compose-files-master/hyperledger_fabric/latest$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 93a6fec14695 yeasy/hyperledger-fabric-peer:latest "peer node start" About an hour ago Up About an hour 0.0.0.0:7051-7053->7051-7053/tcp peer0.org1.example.com e02629f57b4d yeasy/hyperledger-fabric-peer:latest "peer node start" About an hour ago Up About an hour 0.0.0.0:10051->7051/tcp, 0.0.0.0:10052->7052/tcp, 0.0.0.0:10053->7053/tcp peer1.org2.example.com e81a7f2c84b3 yeasy/hyperledger-fabric-peer:latest "peer node start" About an hour ago Up About an hour 0.0.0.0:9051->7051/tcp, 0.0.0.0:9052->7052/tcp, 0.0.0.0:9053->7053/tcp peer0.org2.example.com e3509ea31cf0 yeasy/hyperledger-fabric-peer:latest "peer node start" About an hour ago Up About an hour 0.0.0.0:8051->7051/tcp, 0.0.0.0:8052->7052/tcp, 0.0.0.0:8053->7053/tcp peer1.org1.example.com 3e9c6e6cd9ea yeasy/hyperledger-fabric:latest "bash -c 'cd /tmp; s…" About an hour ago Up About an hour 7050-7054/tcp fabric-cli b1a95fc6bc7a yeasy/hyperledger-fabric-orderer:latest "orderer start" About an hour ago Up About an hour 0.0.0.0:7050->7050/tcp orderer.example.com

then i tried to start the explorer:

xx@ubuntu:~/projects/data/hyperledger/fabric/docker-compose-files-master/hyperledger_fabric/latest$ docker run -d yeasy/blockchain-explorer 60b7f96ac3854c82cbddbc7bd04b615e289b4ffeee4aa318d35c299f6aedb8c0

then i got:

xx@ubuntu:~/projects/data/hyperledger/fabric/docker-compose-files-master/hyperledger_fabric/latest$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b9e2f9b87165 yeasy/blockchain-explorer "bash start.sh" 5 seconds ago Exited (0) 3 seconds ago zen_joliot 93a6fec14695 yeasy/hyperledger-fabric-peer:latest "peer node start" About an hour ago Up About an hour 0.0.0.0:7051-7053->7051-7053/tcp peer0.org1.example.com e02629f57b4d yeasy/hyperledger-fabric-peer:latest "peer node start" About an hour ago Up About an hour 0.0.0.0:10051->7051/tcp, 0.0.0.0:10052->7052/tcp, 0.0.0.0:10053->7053/tcp peer1.org2.example.com e81a7f2c84b3 yeasy/hyperledger-fabric-peer:latest "peer node start" About an hour ago Up About an hour 0.0.0.0:9051->7051/tcp, 0.0.0.0:9052->7052/tcp, 0.0.0.0:9053->7053/tcp peer0.org2.example.com e3509ea31cf0 yeasy/hyperledger-fabric-peer:latest "peer node start" About an hour ago Up About an hour 0.0.0.0:8051->7051/tcp, 0.0.0.0:8052->7052/tcp, 0.0.0.0:8053->7053/tcp peer1.org1.example.com 3e9c6e6cd9ea yeasy/hyperledger-fabric:latest "bash -c 'cd /tmp; s…" About an hour ago Up About an hour 7050-7054/tcp fabric-cli b1a95fc6bc7a yeasy/hyperledger-fabric-orderer:latest "orderer start" About an hour ago Up About an hour 0.0.0.0:7050->7050/tcp orderer.example.com d9a42d3844ba f2a91732366c "/hello" 10 days ago Exited (0) 10 days ago eager_murdock

the explorer exit. what am i missing?

yeasy commented 6 years ago

The problem might be that the latest code is always changing. You can take a look at the hyperledger cello project, which helps start a chain with blockchain explorer.

yshurik commented 6 years ago

Yes, "latest" just does not work at all. When investigated inside container to start.sh and check logs:

# cat log.log 
postgres://hppoc:password@127.0.0.1:5432/fabricexplorer
fs.js:642
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open 'fabric-path/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt'
    at Error (native)
    at Object.fs.openSync (fs.js:642:18)
    at Object.fs.readFileSync (fs.js:510:33)
    at setupPeers (/blockchain-explorer/app/helper.js:60:19)
    at Object.createDefault (/blockchain-explorer/app/helper.js:50:4)
    at Object.start (/blockchain-explorer/app/timer/timer.js:38:12)
    at Object.<anonymous> (/blockchain-explorer/main.js:25:7)
    at Module._compile (module.js:577:32)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)

Any hint to fix?

tballast commented 6 years ago

@yshurik when you launch the container you need to make sure that the certificates are available so that explorer can see them. This line: Error: ENOENT: no such file or directory, open 'fabric-path/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt' is the real problem. Make sure that file is available and you should, at worst, get some new errors!

yshurik commented 6 years ago

@tballast I do not have org1.example.com as I placed some real name, are there options or setup to use non-example namings?

tballast commented 6 years ago

mmm, I see. I'm sure that naming is described somewhere in the documentation somewhere but I'm not 100% sure. What does your docker-compose file look like?

For example, here's a snippet of one that I used (head's up, I'm learning as well so this thing probably isn't perfect, but it ran at least):

  explorer:
    extends:
      file: base.yaml
      service: explorer-base
    container_name: explorer
    restart: always
    hostname: explorer
    depends_on:
      - mysql
      - postgresql
    volumes:
      - ../explorer/config.json:/blockchain-explorer/config.json
      - ../channel/crypto-config:/crypto-config
      # - ../channel/crypto-config:/blockchain-explorer/crypto-config
    ports:
      - 8081:8080  # HTTP port

You can see there is a volume mount. Furthermore, as part of config.json for explorer, I have the following:

      "org1": {
         "name": "peerOrg1",
         "mspid": "Org1MSP",
         "peer1": {
            "requests": "grpc://peer0.org1.example.com:7051",
            "events": "grpc://peer0.org1.example.com:7053",
            "server-hostname": "peer0.org1.example.com",
            "tls_cacerts": "/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
         },
         "peer2": {
            "requests": "grpc://peer1.org1.example.com:7056",
            "events": "grpc://peer1.org1.example.com:7058",
            "server-hostname": "peer1.org1.example.com",
            "tls_cacerts": "/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"
         },
         "admin": {
            "key": "/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore",
            "cert": "/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts"
         }
      }

So, the config.json file tells it where to look, and you need to make sure that when you launch the container that you've actually mounted a local directory that has those keys in the right spot. Either that, or create a container that has everything already in it. But I'd recommend the former.

adam-hrdie commented 6 years ago

hi @tballast thanks for the info.

I am also having issues getting this image to run properly. Can you please share how your base.yaml file sets up the explorer image? As I am having problems mounting my crypto config bits into the following setup

  explorer:
    image: yeasy/blockchain-explorer:latest
    hostname: explorer
    environment:
      - HYP_REST_ENDPOINT=http://localhost:7051
    volumes:
      - ./explorer/config.json:/blockchain-explorer/config.json
      - ./crypto-config:/crypto-config/
    ports:
      - "9090:9090"
    expose:
      - "9090"
yeasy commented 6 years ago

Pls refer to https://github.com/yeasy/docker-compose-files/blob/master/hyperledger_fabric/v1.0.6/docker-compose-2orgs-4peers-solo-be.yaml for a complete running env.