** Important Note: Parts of this article are now obsolete, please check the update: Running Hyperledger Fabric on Windows – Revised. **

My colleague Chris Ferris recently posted on how he got to run the Hyperledger Fabric natively on Mac. Knowing that I have a Windows machine he prompted me to try and do the same on Windows. So I did and here is what I can say about my experiment.

“Natively”

First, I need to say that in my case I have to put “natively” between quotes because the Windows machine I have is running Windows 7 and Docker doesn’t actually run natively on that version of Windows. Docker currently only runs natively on Windows 10. For older versions of Windows you have to use the Docker Toolbox which actually runs Docker in a linux VM.

VirtualBox

If you haven’t installed VirtualBox yet you first need to do that. The installation is very straightforward, the only possible gotcha is that you need to make sure virtualization is on on your machine. This is set via the BIOS menu so if it doesn’t work you will need to reboot your machine to change that setting.

Having already installed VirtualBox on my machine I had that already taken care of.

Docker

As explained above I couldn’t run Docker natively on my machine so I installed Docker Toolbox. This was very straightforward. Once the installation ends you simply launch the “Docker Quickstart Terminal” and you’re on your way.

The command actually provisions a linux VM in VirtualBox with Docker. You can see the running VM by opening the VirtualBox Manager.

Note that on starting the Docker Quickstart Terminal I get an error message saying that bash: .bashrc: No such file or directory but that’s not a problem.

Hyperledger Fabric

You then need to create a file docker-compose.yml similar to the one Chris created for running on Mac.

To make it easy you can simply copy paste the following or copy compose-defaults.yml from the fabric distribution and then make the same two changes Chris discussed to 1) change the endpoint and 2) add a port mapping.

Your docker-compose.yml file should then contain the following:

vp:
  image: hyperledger/fabric-peer
  ports:
    - "5000:5000"
  environment:
    - CORE_PEER_ADDRESSAUTODETECT=true
    - CORE_VM_ENDPOINT=http://localhost:2375
    # TODO:  This is currently required due to BUG in variant logic based upon log level.
    - CORE_LOGGING_LEVEL=DEBUG
  # Startup of peer must be delayed to allow membersrvc to come up first
  command: sh -c "sleep 5; peer node start"
  #command: peer node start
  
  # Use these options if coverage desired for peers
  #image: hyperledger/fabric-peer-coverage
  #command: ./peer.test --test.coverprofile=coverage.cov node start
membersrvc:
   image: hyperledger/fabric-membersrvc
   command: membersrvc

With this being done you can then fire up an Hyperledger Fabric peer with the following command:

docker-compose up

This will fetch the Hyperledger Fabric container from the cloud using Docker Hub and launch it within the VM that is running.

This may take a bit of time at first as it downloads the workload from the net but eventually you should start seeing log messages scrolling through your terminal window indicating that the Fabric peer is running and waiting for requests like this:

...
[36mvp_1          |[0m 21:06:38.558 [rest] StartOpenchainRESTServer -> INFO 030[0m Initializing the REST service on 0.0.0.0:5000, TLS is disabled.
[36mvp_1          |[0m 21:06:44.558 [peer] ensureConnected -> INFO 031[0m Touch service indicates no dropped connections
[36mvp_1          |[0m [36m21:06:44.558 [peer] ensureConnected -> DEBU 032[0m Connected to: []
[36mvp_1          |[0m [36m21:06:44.558 [peer] ensureConnected -> DEBU 033[0m Discovery knows about: []
[36mvp_1          |[0m 21:06:50.558 [peer] ensureConnected -> INFO 034[0m Touch service indicates no dropped connections

Up to that point my experience had been so smooth it made me wonder if it was really running! So, I decided to go one step further and try to connect to it and check that it was indeed running.

Connecting to your peer

There are different ways one can interact with an Hyperledger Fabric peer but of course the easiest way to do a simpe test is to use the REST API. That’s the power of the web, all you need is a web browser.

One very simple request you can make to your peer is for the list of peers running in the network. This can normally be done by pointing your browser to: https://localhost:5000/network/peers

Unfortunately this is where things became difficult for me. First, I already knew that port 5000 isn’t available on Windows. It is used by the OS so you have to map it to a different port, say 3000.

At this point I thought all I had to do was to change my docker-compose.yml file to map port 3000 to 5000 but that didn’t work. It took me a while to understand but after many tries I figured it out so I’ll just give you the solution and spare you with my fruitless wandering.

What you need to understand is that in this setup, with the Docker Toolkit, you actually have two different levels of port mapping. First there is a mapping between the container and the linux VM docker runs in, then there is a mapping between the linux VM and Windows. The mapping specified in your docker-compose.yml file only affects the former. For the latter you need to set that on VirtualBox.

To set the second mapping launch the VirtualBox Manager.
VirtualBox

Select the running VM called “default”. Click on “Settings”. Select “Network”.
VirtualBox2

Open the “Advanced” section and click on “Port Forwarding”. Click the “Adds new port forwarding rule” button on the right (the green diamond with a plus sign). Then set Host Port to 3000 and Guest Port to 5000.

VirtualBox3

Click Ok. That’s it.

Now, point your browser to https://localhost:3000/network/peers
You should get a page returned from your running peer listing one peer:

Network_peers

Congratulations! You have successfully connected to your peer.

19 comments on"Running Hyperledger Fabric “Natively” on Windows"

  1. Philip Bawa August 25, 2016

    Installed through your instructions in Ubuntu Xenial, but where are we supposed install docker-compose.yml?

    docker ps and docker-compose up are throwing blanks.

    • Philip Bawa August 25, 2016

      $ whereis docker
      copied the docker-compose.yml into all the paths
      Now from docker ps:

      root@philip-MXC061:/home/philip# docker ps
      /usr/bin/docker: line 1: vp:: command not found
      /usr/bin/docker: line 2: image:: command not found
      /usr/bin/docker: line 3: ports:: command not found
      /usr/bin/docker: line 4: -: command not found
      /usr/bin/docker: line 5: environment:: command not found
      /usr/bin/docker: line 6: -: command not found
      /usr/bin/docker: line 7: -: command not found
      /usr/bin/docker: line 9: -: command not found
      /usr/bin/docker: line 11: command:: command not found
      /usr/bin/docker: line 17: membersrvc:: command not found
      /usr/bin/docker: line 18: image:: command not found
      /usr/bin/docker: line 19: command:: command not found

    • You can just put that file anywhere you want, by default docker-compose will look for the file in the current directory. If you have it somewhere else you will need to tell docker-compose where to find it through command line options:

      docker-compose -f yourfile

  2. Sandeep Saxena November 25, 2016

    Excellent step by step guide @Lehors, thanks for that. Can you please also suggest on ways to connect through a proxy – where do i do the proxy config? Am running Windows 10 so the Virtual Box was not required and was able to run the peer on an open network as per the above instructions but when I came into my work env, and tried to startup, it would not – figure that’s a proxy issue but how do i deal with it?

  3. abhinav.garg@sakshay.in December 07, 2016

    please let me know how to setup hyperledger for making blockchains.
    I need step by step procedure for windows 7.
    ping me some docs on abhinav.garg@sakshay.in

  4. Rasmus Thorsøe January 19, 2017

    I am having some problems getting this running. The peer and the membersrvc appear to be running fine, i am getting the same console output as you. I changed the port forwarding in the .yml file to 3000:5000 (also tried 5000:3000 as i was not sure which one) . I also added the port forwarding in VirtualBox, as per the screenshot. However when i go to https://localhost:3000/network/peers i am getting connection reset/aborted. Any ideas as to what the problem might be? In the console it also does not seem like the peer has received anything.

    • I am also not getting connected to the peers from web browser with port 3000. Please suggest us further

    • 1. set 7050:7050 in the .yml file
      2. adder the port forwarding in VirtualBox 8899 to 7050
      3. http://127.0.0.1:8899/network/peers
      bingo

      • also you can go to http://192.168.99.100:7050/network/peers to display peers.
        192.168.99.100 is your virtualbox address

        • I have set 7050:7050 in .yml file and I can also see that Virtual Box is associated with 192.168.99.100 on port 7050 but I am unable to get the list of peers associated running on VM. PFB is the output which I see after starting the docker-compose on the terminal.

          Name , IP NetworkID of the two peers which are started.

          Also I see following in the container logs present on the Virtual Host

          2017-11-12 09:54:41.616 UTC [chaincode] Execute -> DEBU 191 Exit
          2017-11-12 09:54:41.616 UTC [sccapi] deploySysCC -> INFO 192 system chaincode qscc/(github.com/hyperledger/fabric/core/chaincode/qscc) deployed
          2017-11-12 09:54:41.616 UTC [nodeCmd] initSysCCs -> INFO 193 Deployed system chaincodess
          2017-11-12 09:54:41.617 UTC [nodeCmd] serve -> INFO 194 Starting peer with ID=[name:”jdoe” ], network ID=[dev], address=[172.17.0.2:7051]
          2017-11-12 09:54:41.620 UTC [nodeCmd] serve -> INFO 195 Started peer with ID=[name:”jdoe” ], network ID=[dev], address=[172.17.0.2:7051]
          2017-11-12 09:54:41.620 UTC [flogging] setModuleLevel -> DEBU 196 Module ‘msp’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.620 UTC [flogging] setModuleLevel -> DEBU 197 Module ‘msp/identity’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.620 UTC [flogging] setModuleLevel -> DEBU 198 Module ‘configvalues/msp’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.620 UTC [flogging] setModuleLevel -> DEBU 199 Module ‘gossip/discovery’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.620 UTC [flogging] setModuleLevel -> DEBU 19a Module ‘gossip/election’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.620 UTC [flogging] setModuleLevel -> DEBU 19b Module ‘gossip/comm’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.620 UTC [flogging] setModuleLevel -> DEBU 19c Module ‘gossip/gossip’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.620 UTC [flogging] setModuleLevel -> DEBU 19d Module ‘gossip/service’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 19e Module ‘peer/gossip/mcs’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 19f Module ‘peer/gossip/sa’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 1a0 Module ‘gossip/state’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 1a1 Module ‘gossip/pull’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 1a2 Module ‘kvledger’ logger enabled for log level ‘INFO’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 1a3 Module ‘kvledger.util’ logger enabled for log level ‘INFO’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 1a4 Module ‘ledgermgmt’ logger enabled for log level ‘INFO’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 1a5 Module ‘cauthdsl’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 1a6 Module ‘policies’ logger enabled for log level ‘WARNING’
          2017-11-12 09:54:41.621 UTC [flogging] setModuleLevel -> DEBU 1a7 Module ‘grpc’ logger enabled for log level ‘ERROR’

          • Sorry for the late reply. Unfortunately due to the major redesign Fabric went through the REST API was dropped from Fabric as of Fabric 1.0. So accessing the peers in the way described here no longer works. A new REST API is under development.
            The problem with port forwarding for those who rely on Docker Toolbox still exists though and will surface in any of the work related to fabric-ca or the fabric-node-sdk.

  5. Hi, I am a beginner in blockchain technology.
    Could you please help me with installation process of hyperledger fabric on windows 7.
    I mean to say i am confused with what has to be installed and what not. i find so many dockers ,node.js sdks etc etc.
    It would be of great help if get to know the step by step process.

  6. alekseygrud March 02, 2017

    An excellent guide

  7. […] Execute o Hyperledger Fabric nativamente no Windows […]

  8. It is very helpful. Thanks.

  9. Matthias Kloppmann April 19, 2017

    Thanks for the instructions and comments, had most of it running already, but was struggling getting the ports opened up to my local (Win7) machine – now that works.
    My next step is to get a local instance of Fabric Composer to connect to it. I can see a connection profile embedded in the docker-compose.yml file (which I got from the Fabric Composer Getting Started tutorial), so that part should be obvious. However: Where do I have to physically put the connection profile on Windows? I know it needs to go into $HOME/.composer-connection-profiles, but what is the Win equivalent of that?

  10. […] started with this post. The post is clean and perfectly what I needed. It mentions that since native Docker is […]

  11. I installed VirtualBox and Docker Toolbox. When I launch Docker QuickStart Terminal I get the message:

    bash: fork: retry: No child processes
    7583759 [main] bash 3460 C:\Program Files\Git\bin\..\usr\bin\bash.exe: *** fatal
    error in forked process – MapViewOfFileEx ‘(null)'(0x160), Win32 error 5. Term
    inating.

    Any idea how to resolve this?

    Thanks.

Join The Discussion

Your email address will not be published. Required fields are marked *