Hyperledger Fabric on windows
In this article we are going to explore Hyperledger Fabric installation on windows machine, basically a setup for development environment. Hyperledger Fabric is permissioned dristributed ledger.
My main intention to write this post is to help people who want to get started with hyperledger and their primary operating system is windows.
We are going to user Windows 10, with OS build version 19041 or higher because that's minimum version required by WSL(Windows Subsystem for Linux).
WSL lets developers run Linux environment on windows machine as a sub system.
We will install WSL2 on windows machine manully
Open power shell in Admin mode.
Note: To use WSL2 below mentioned OS Build is needed
-
Enable windows SubSystem for Linux
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem Linux /all /norestart
After running above command to verify that Windows subsystem is enabled refer to below image
-
Enable Virtual Machine feature
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
After running above command to verify that Virtual machine platform is enabled refer to below image
-
Download linux kernel update package:
To update the WSL package download setup at the below-mentioned link, it needs admin privilege.
WSL2 Linux kernel update package for x64 machines
-
Set WSL-2 as default version
wsl --set-default-version 2
WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel
For information on key differences with WSL 2 please visit https://aka.ms/wsl2 -
Install Ubuntu app from windows store:
- Open the Microsoft Store and install Ubuntu 20.04 LTS here
-
Install windows terminal
- It enables multiple tabs, quickly between the Linux command line and the windows command prompt.
Note: Above terminal is a utility and it is very productive.
- It enables multiple tabs, quickly between the Linux command line and the windows command prompt.
-
Ubuntu command line setup:
Note: You have to run the Windows terminal with Administrator rights.
- Open Windows Terminal and add a new ubuntu tab, you won’t be able to see the ubuntu terminal. Under add new terminal section.
- Open Installed, “Ubuntu 20.04 LTS” once, So that it will be linked with Windows terminal.
- After following step 2 then Ubuntu will be registered with Windows Terminal.
- Open Windows Terminal and add a new ubuntu tab, you won’t be able to see the ubuntu terminal. Under add new terminal section.
-
Updating and installing basic packages for Ubuntu.
sudo apt update && sudo apt upgrade
for more detail, please refer here. -
Docker Installation on Windows
System requirement for docker installation on windows 10 OS builds version 1903 or higher.we have already enabled WSl2 on windows refer steps 1-4
-
Virtualization should be enabled on the windows machine, most of it supports
-
Download Docker for windows latest version from here
-
Install Docker
-
Open docker and it will be running in apptray
-
To check docker version run following below command
docker –version
docker-compose --version
-
-
Enable Docker for ubuntu
- Go to Settings
- Resources
- WSL integration
- Enable Ubuntu-20.04
- Then hit Apply & restart
- This may take few minutes
- After Enabling this we will get docker in the ubuntu command line
- Run following command to check if you are able to access it on Ubuntu
docker –version
docker-compose --version
-
Hyperledger fabric installation on Linux(Ubuntu)
Run following command to install and update basic packages on Ubuntu
sudo apt update
sudo apt upgrade
After running above command most of common required packages will be in installed.
We need to make sure below following packages will be installed.-
cURL
Check if cURL already exists
curl -v
If cURL doesn't exists then install it via following command
sudo apt-get install curl
-
Go
Check if Go lang exists
go version
If Go doesn't then install with following steps:
Download the Go lang package for Linux from here.sudo wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz
The following command will extract the zip file at the downloaded location
tar xvf go1.16.3.linux-amd64.tar.gz
Set GOPATH using following commandexport GOPATH=$HOME/go
export PATH = $PATH:$GOPATH/bin
Run the following command to verify that Go lang is installed successfully
go version
-
Docker
Doker we have already installed in the previous section and with help of WSL.
Run the following command to verify it`docker --version`
docker-compose --version
-
Git
Run the following command to if git is installed
git --version
-
-
Install Hyperledger Fabric and Fabric samples
Note: Hyperledger fabric version is 2.3.2
-
Create a directory with following command
Creates a new Directory:mkdir -p $HOME/go/src/github.com/
Navigate to that created directory:cd $HOME/go/src/github.com/
-
Download the latest release of fabric samples and docker images.
The following link will clone Fabric-samples located at
https://github.com/hyperledger/fabric-samples
Run following command under$HOME/go/src/github.com/
directory
curl -sSL https://bit.ly/2ysbOFE | bash -s
-
After running below respective images will be downloaded to docker
-
After downloading, your folder structure looks like below
-
Open folder in your favourite editor, mine is vscode
simply run following command
code .
Note: if you don't have installed vscode it will install first then you
need to run same command again
-
-
Running fabric test network:
- Open windows terminal and navigate to fabric folder
cd $wsl
cd go/src/github.com/fabric-samples
- Go to test-network
cd test-network
- Run following command to remove existing any container or artifacts form previous run.
./network.sh down
- Running following will boot up fabric test network
./network.sh up
- Run following command to list down all running docker images in docker
docker ps -a
Same you can look at docker GUI
- Open windows terminal and navigate to fabric folder
Now, we have succesfully installed and ran fabric on windows machine.
I hope this helps you to set up hyperledger fabric on windows machine
thanks for this!! I was running into many binary/config errors along the setup process even while using WSL but this clarified it… bump for the algo! Very helpful article - bookmarked!
Great to hear that. let me know if you need me to write on another topic that might help you!!
Thanks bud! If I hit any serious roadblocks I’ll reach out here and trade work for guidance if need be - I can code ya something but I’m fairly certain it should be fairly simplistic or straight-forward from what I’ve done with HLF so far but I’ll def reach out if need be :D
Hi,
I am having trouble installing vscode in Docker. Having an error @ “code .”
Help please
Great compilation steps… saved hell amount of time for configuring on windows 10 Home
did you able to setup Successfully following the steps?