This is a tutorial for setting up the development environment to create a Hyperledger Fabric network on windows. Hyperledger is an open source distributed ledger framework by Linux Foundation.
Hyperledger Fabric - Hyperledger
Hyperledger Fabric is intended as a foundation for developing applications or solutions with a modular architecture…
Enable the Windows developer mode
First of all we have to enable the windows developer mode in order to create any fabric based application. You can find the developer mode in windows developer settings.
The next thing is to enable the Windows Subsystem for Linux. Since hyperledger fabric heavily depends on Unix commands it’s better to develop it on UNIX environments like Ubuntu or MacOS. In this tutorial we will be using ubuntu on top of windows.
Now open the Microsoft Store and Install Ubuntu application. It will take some time to download the application as per your internet connection. It will help us to get the Ubuntu terminal on top of windows so we don’t have to install Linux system separately.
Once the application is installed you can start the ubuntu app and configure the username and password.
As we are done with the windows features and installing the Ubuntu application, we move on to the next step which is installing Docker. Docker is a software platform that provides the ability to package and run an application in an isolated environment called the container.
Empowering App Development for Developers | Docker
Docker offers free plans for individual developers and teams just starting out. We also have new monthly plans for…
As we are using Ubuntu on top of windows we need to install docker on both the environments i.e. the windows environment and the Linux subsystem on top of windows. We need to map the docker for both the environments because Ubuntu is running as a virtual machine and doesn’t have the idea about the actual hardware (as docker is a containerization tool we need to tell it what kind of hardware we are using).
Firstly we will install docker on windows environment. You can directly download and install docker from the link given below.
Docker Desktop for Windows - Docker Hub
The fastest and easiest way to get started with Docker on Windows
Now that docker is installed on our windows environment we will install Docker on our Ubuntu VM. For that you will need to execute the following commands in your Ubuntu terminal.
sudo apt-get update — This command is used to install all the dependencies from Ubuntu source.
sudo apt install curl — To install curl package because curl is a tool set which we will use in order to get any third-party libraries.
We can install docker on Ubuntu by following the below walk-through steps provided by the docker itself.
Install Docker Engine on Ubuntu
Estimated reading time: 11 minutes To get started with Docker Engine on Ubuntu, make sure you meet the prerequisites…
Step 1 — Setup the repository
$ sudo apt-get update
$ sudo apt-get install \
This will install different dependencies require to install docker. These dependencies includes some common tools and also includes some CA certification tools.
Step 2 — Add Docker’s official GPG key
Now we will use curl to fetch the docker’s official key which is used to verify the downloaded docker on top of Linux.
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Step 3 — Verify that you now have the key with the fingerprint
Now we will verify the fingerprint of the key in order to verify that we are getting the correct version of docker.
$ sudo apt-key fingerprint 0EBFCD88
Step 4 — Setup the stable repository
In this step we will install the latest docker repository. This is a stable version of docker for our environment.
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
Step 5 — Install docker engine
The final step is to install the docker community tools using the following commands.
$ sudo apt-get update
$ sudo apt-get install docker-ce
With this the docker installation is completed. The next step is to install Docker Compose so that we can run multiple peers on our system.
To install docker - compose run the following commands in your Ubuntu terminal.
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Now we will provide permissions to the binary file we have just downloaded.
sudo chmod +x /usr/local/bin/docker-compose
With this our docker and docker-compose installation is completed. The next thing is to map the docker on Ubuntu to the docker we have installed on our windows environment.
Now we will install go language using the following command.
curl -0 https://storage.googleapis.com/golang/go1.11.2.linux-amd64.tar.gz
this command will install a zip file which can be unzipped by using the following tar command
tar -xvf go1.11.2.linux-amd64.tar.gz
after the unzipping has finished we will move our go binaries to usr/local so that user can have direct access to them.
sudo mv go /usr/local
Open the docker desktop which we have installed on windows environment and expose the daemon tools on tcp://localhost:2375. This is the port which we are going to use to map our windows machine to our Linux machine.
Our windows docker will act as host docker which knows about the hardware and our linux docker will act as the client.
Now we will setup an environment variable containing the tcp port information and will store that in the bashrc file. bashrc file is the bootstrap file which is executed every time the Ubuntu system is up and running.
sudo echo "export DOCKER_HOST='tcp://0.0.0.0:2375'" >> ~/.bashrc
Now we will rebuild the bashrc file using the source command.
Installing NodeJS and NPM
In order to install NodeJS we will first fetch the current stable repository.
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
The following command is use to fetch the current public key which will verify that our installation is correct for nodeJs, just like we have done in case of docker.
curl -s https://deb.nodesource.com/gpg.key/nodesource.gpg.key | sudo apt-key add -
Now we will install node and the npm.
sudo apt update
sudo apt install nodejs
sudo apt install npm
With this we came to the final step of this tutorial which is to share our windows folder with our linux subsystem.
Before sharing folder make sure that the windows firewall is disabled because it might issue while sharing the folders.
The next thing we are going to do is to make sure that our C drive is open for sharing. For that you have to go to Sharing in C drive properties and then Advance Sharing. Inside Advance settings go to the permissions and make sure that the permissions are open to all.
Now our C drive is available to be shared with our Ubuntu VM and we can directly mount our C drive on top of Ubuntu.
We can mount the C drive on Ubuntu and can check the file system using following command
With this your development environment is all set for creating a hyperledger network. You can test it by running a sample network which is available on Hyperledger GitHub page.