Understanding Hyperledger Explorer Setup via Docker

Davor Kljajic
6 min readJun 5, 2019

In this article, we will explain the process of setting up the Hyperldger Explorer using the Docker.

We are going to explain all the issues which we had and how we resolved them when we were doing setup on our custom blockchain network.

Before we start: Hyperldger Explorer is an open-source browser for viewing activity on the defined blockchain network, in our case Hyperldger Fabric.

Explorer adds an essential element to operations in the world of private enterprise blockchains and is meant to be a valuable tool when blockchain’s immutable ledger needs to be accessed and examined.

Of course, it is not necessary to emphasize that the blockchain network should be pre-set :). You can use any network from Fabric Samples.

We decided for this kind of setup because the whole process is automated and the components of the Hyperldger Fabric network are shipped via Docker.

The following are requirements are for installing the required development tools:

We will clone the repository and examine the crucial files for setting up the Hyperldger Explorer.

git clone https://github.com/hyperledger/blockchain-explorer.git

The files and folder that we will examine:

  • docker-compose.yaml
  • config.json
  • connection-profile
  • keychain(folder)

docker-compose.yaml

docker-compose.yaml

As you can see, we have 2 more additional containers beside explorer.mynetwork.com and explorerdb.mynetwork.com: grafana and proms.

They are open source monitoring and notification tools. Our focus will be on “explorer containers”. Below we will go through the sections of the document.

The Hyperledger Explorer will have own network (independent from blockchain network) and must be connected with the blockchain network. To inspect your deployed blockchain network, you can do it with these commands:

// list docker networkdocker network ls// inspect docker networkdocker network inspect {network_name}

In the section networks, we are telling Docker about the external network.

The name of Hyperledger Explorer network is “mynetwork.com” in our case blockchain network is called “network_default”.

The section volume in the explorer.mynetwork.com container is the most important for explorer functionality and to get things done.

As you can see, we are mounting a config.json, connection-profile and folder keychain.

These 3 things will be used in our virtual environment to connect on the blockchain network. That is why all paths defined in connection profile are mounted paths.

The paths that are defined left, are your local paths on your machine, while the right defined paths, after “:” present the paths in the docker container (mounted paths).

When you connect the explorer to your fabric network through a bridge network, you need to set DISCOVERY_AS_LOCALHOST to false for disabling hostname mapping into localhost.

After defining the local paths and the paths inside the docker container, we can go on the second file.

config.json

config.json

We mounted the path in the docker-compose.yaml to the config.json, that file will provide the path to the connection profile.

  • “bow-network” is the name of your connection profile, and can be changed to any name.
  • “name” is a name you want to give to your fabric network, you can change the only value of the key “name”.
  • “profile” is the location of your connection profile, you can change the only value of the key “profile”. Mounted path!

NOTE: With one Blockchain Explorer Setup you can monitor multiple networks.

connection-profile.json

The main goal of the connection profile is to create a network topology for the Hyperledger Explorer and give the credentials in shape of certificates to access the blockchain network.

NOTE: Most errors have been made here:

Provide the path to the adminPrivateKey config option, it usually ends with “_sk”, for example:

"/tmp/crypto/peerOrganizations/central.bow-blockchain.com/users/Admin@central.example.com/msp/keystore/aaacd899a6362a5c8cc1e6f86d13bfccc777375365bbda9c710bb7119993d71c_sk"

As we said earlier, the reason for this mounting is that we must use the path that we defined in the docker container in the section volume (right side).

You can use your own path for mounting but be careful here. The error that is occurred if the paths aren’t correct is that that file doesn't exist.

  • adminUser” is the admin user of the organisation in the blockchain network, in this case, it’s fabric CA issued identity.
  • adminPassword” is the password for the admin user of the organisation. In this case CentralMSP
  • enableAuthentication” is a flag to enable authentication using a login page, setting to false will skip authentication.

When setting up Hyperldger Explorer we had an error saying that peer communication cannot be established. The problem was the inappropriate port.

In section “peers” you must provide the ports that you expose for that specific peer. To find that port you can find in the docker-compse.yaml file for your blockchain network. In section ports for that peer exposed ports are on the right side. In our case for the peer in the central organization — 10051:7051 so we used the(7051).

Keychain Folder

This file contains the certificates and artefacts of the blockchain network that we want to put Hyperldger Explorer. In our case, we copied them from our blockchain network to examples/net1/keychain folder.

Over docker-compose.yaml file we mounted that folder into /tmp/crypto inside our Docker container and that is the path which we used for certificates.

NOTE: Certificates and artefacts are confidential data and sometimes have different permissions, we have the problem that keychain folder that isn’t executable in our system. So it is necessary to change some permissions with Linux command:

sudo chmod 775 -R name_folder

Start Hyperledger Explorer

Run the following to start up explore and explorer-db services after starting your fabric network:

cd /blockchain-explorer docker-compose up -d

Login in and you will see the section dashboard.

To stop services without removing persistent data, run the following:

docker-compose down

In this docker-compose.yaml, two named volumes are allocated for persistent data (for Postgres data and user wallet), if you would like to clear these named volumes, run the following:

docker-compose down -v

Errors and troubleshooting

postgres://hppoc:password@192.168.10.11:5432/fabricexplorer
error when connecting to db: { error: role "hppoc" does not exist

The initialization of the database might fail for some reasons. You need to clear the persistent data by running the following command. Or you can find in the folder Dockerfile which will create an image to create custom docker containers.

docker-compose down -v
docker-compose up -d

The Explorer might not have connected the network which your fabric network is belonging.

<<<<<<<<<<<<<<<<<<<<<<<<<< Explorer Error >>>>>>>>>>>>>>>>>>>>>
Error : [ 'Default client peer is down and no channel details available database' ]

In such a case, you need to check whether the explorer container has belonged to the same network with your fabric network or not, with the following command.

docker network inspect network_name 

To summarize first we clone the repository, put the crypto material from our network. Set the files and folders on the place that we defined in the docker-compose.yaml and start the Docker containers.

Conclusion

Hyperledger Explorer allows us to inspect and visualize the blockchain network as such an inevitable element of every blockchain solution.

It is a great tool to assess or audit any actions within your network. I see a lot of potential of using it in a production environment.

There are many questions within the community about setting up Hyperledger Explorers, so we decided to share our knowledge with you. Thank you for reading and if you have any questions, feel free to ask.

Work with us!

Beyondi offers high-quality services: Web Development and Design, Mobile Development and Design, Embedded Solutions, Blockchain Solutions, SEO, Growth and Team Augmentation? You can find more about our services on our website.

--

--