Windows 10 64 bits Hyperledger Explorer setup using Docker.
A running Hyperledger Fabric network.
I used Hyperledger Fabric v1.2. See Hyperledger Fabric documentation.
I included the configuration for an example network (app/config/configtx.yaml and app/config/crypto-config.yaml files).
Also don't forget to configure Git for Windows :
Check autocrlf :
git config --get core.autocrlf
if null
or true
, set it to false
:
git config --global core.autocrlf false
Check longpaths :
git config --get core.longpaths
if null
or false
, set it to true
:
git config --global core.longpaths true
In case you already set up the environment, here are some useful cleanup commands
-
Clean containers and volumes
docker-compose down
-
Clean all containers containing "blockchain-explorer" in their name
docker stop $(docker ps -a --filter="name=blockchain-explorer") docker rm $(docker ps -a --filter="name=blockchain-explorer")
-
Clean all images with name starting with "hyperledger-blockchain-explorer" or "dev-peer"
docker rmi $(docker images hyperledger-blockchain-explorer* -q)
-
Prune networks and volumes
docker network prune docker volume prune
-
Remove crypto materials
rm -rf app/config/crypto-config/
The Hyperledger network in which I ran this example is composed of :
- 2 organizations :
- myorg1
- myorg2
- 2 peers per organization :
- myorg1 : peer0.myorg1.ch and peer1.myorg1.ch
- myorg2 : peer0.myorg2.ch and peer1.myorg2.ch
- peer0 from both organizations have been defined as anchor peer
- all peers use CouchDB as ledger state database
- 1 user (identity) per peer (in addition to Admin user)
- 1 orderer (use its own channel orderer-channel) with kafka consensus
- 1 channel my-channel joined by both peer0 from both organizations
- 1 Go chaincode
- 4 Kafka nodes and 3 Zookeeper (as recommended)
- 2 Certification authorities (one per organization)
See app/config/configtx.yaml and app/config/crypto-config.yaml for example configuration and Hyperledger Fabric documentation for the setup.
I have built a custom setup, that I think is simpler than the mentioned steps (from the official repository readme file) which consist of downloading the whole repository and then modify the files.
Instead of downloading the repository locally and doing the modification in the sources, I get the repository directly from a Docker container and then link local configuration files to it using volumes.
I used the release-3.5 branch.
You may change the EXPLORER_BRANCH
argument in the docker-compose.yml file if you want to use a different branch (may requires other modifications).
I have implemented a Compose file (docker-compose.yaml) that builds the images/containers for the application and the database. The containers will be attached to the existing Docker network of our Fabric network.
Warning
Make sure you use the same Docker network as your existing Hyperledger Fabric network in the docker-compose.yaml file. Mine is config_mynw
.
The Application will attach to the database once it is ready (I used a wait.sh
script to wait for the database to be up).
The initialization scripts are retrieved from the official repository in the PostGreSQL Dockerfile.
All that you need is in the config directory :
- config.json : file representing the network configuration
- crypto-config : folder containing the network certificates
So just adapt the config.json file and copy the crypto-config folder from the one generated during your Fabric setup. You can regenerate the cryptographic materials from the app/config/configtx.yaml and app/config/crypto-config.yaml files if needed.
Then simply run :
docker-compose up
This will run 2 containers :
hyperledger_explorer_app
: the applicationhyperledger_explorer_postgresql
: the PostGreSQL database
You should be able to reach http://localhost:8092
For Swagger API endpoint, go to http://localhost:8092/api-docs/
If you need to enter the PostGreSQL database manually, here are some useful commands :
Get into the container :
winpty docker exec -it hyperledger_explorer_postgresql sh
Connect to PostGreSQL as postgres
user :
su postgres
psql
or :
psql -U postgres
List all databases :
\list
Connect to the fabricexplorer
database :
\connect fabricexplorer
Select data :
select * from peer;
Quit :
\q
General Public License (GPL) v3
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.