How to Install Hyperledger Fabric in Windows 10
Hyperledger Fabric on Windows 10
Since Hyperledger fabric heavily based on Docker and a bunch of Unix commands. It's much better to develop it on UNIX environments like Ubuntu or MacOS. On Windows 10 we have the option to enable Ubuntu subsystem by following this instruction.
Enable Developers mode
Enable Windows Subsystem for Linux in Windows Features
After we enable the subsystem we will have bash application on windows but It's still lack of some prerequisite command. On my workspace, I need to install the following command
Update apt-get
sudo apt-get update" do? — Ask Ubuntu
Curl
sudo apt install curl
Install docker CE
You will nee d to install docker CE Client in Ubuntu Subsystem and install Docker on Windows as well. But those dockers won't connect together out of the box. We need to expose the daemon to port 2375 first by right-clicking the docker icon on taskbar then click setting then check the Expose daemon box
Now our docker server will be able to connect via Windows network including Ubuntu subsystem. We need to set environment variables in Ubuntu by running
echo "export DOCKER_HOST='tcp://0.0.0.0:2375'" >> ~/.bashrc
This command will add DOCKER_HOST to the variables every time we start a new Bash. On the current bash doesn't have this variable yet so you can open the new one or run this command
source ~/.bashrc
Docker compose
We also need docker-compose for ease of connecting docker together
sudo apt install docker-compose
Install node
NodeJS Version 6 is recommended for developing an application on Fabric
sudo bash -c "cat >/etc/apt/sources.list.d/nodesource.list" <<EOL
deb https://deb.nodesource.com/node_6.x xenial main
deb-src https://deb.nodesource.com/node_6.x xenial main
EOL curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add - sudo apt update sudo apt install nodejs sudo apt install npm
Docker compose has a problem with mounting volume from Windows to Docker. There is a workaround by mounting /mnt/c to /c
sudo mkdir /c
sudo mount --bind /mnt/c /c
Then we create our workspace under /c
mkdir /c/workspace && cd /c/workspace
We should share Drive C to docker as well
Verify that everything is valid by running
docker run — rm -v c:/:/data alpine ls /data
You should see a list of files in Drive C
If not you might need to do these steps
Disabling filewall
Turn on file sharing
Add share permission to Users by right click on Drive C and enter the Permission for C setting then add Users to share permission and make sure you have checked all permissions
If you see errors like this you need to restart docker server
ERROR: for xxx Cannot start service orderer.example.com: driver failed programming external connectivity on endpoint xxx (6877371c7c8995590b96266d224f3fcc7e6cddf449441d4e5ac4b970c97c993a): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:7050:tcp:172.18.0.3:7050: input/output error
Install Hyperledger Fabric
We will install docker images and crypto tools using this command
curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0-previe
Test by Hyperledger fabric samples
Now we will clone a sample project from Hyperledger to confirm that our environment is ready for development
cd /c/workspace && git clone https://github.com/hyperledger/fabric-samples.git && cd fabric-samples/first-network
now we will generate crypto artifacts
./byfn -m generate
It will consume our crypto-config.yaml and configtx.yaml and create files that need for the network not it's time to bring the network up
./byfn -m up
It will bring up peers, ordering service and Cli. The Cli container will run a script file that tests everything on the network from creating a channel, connecting channel, install chaincode, instantiate chaincode, query and invoke the chaincode. If everything went fine you will see this END screen which means you are ready to work with Fabric on your Windows 10
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
How to Install Hyperledger Fabric in Windows 10
Source: https://medium.com/@methuz/hyperledger-fabric-on-windows-10-26723116c636