Hyperledger Fabric v1.0 on a Raspberry Pi Docker Swarm – Part 1

There have already been articles published on the use cases for using IoT with a private Blockchain.  The possibilities are really exciting but what if we could run the blockchain ON our IoT network.  That sounds like a fun project to me!

With that goal in mind and a bit of research I was  led to Hyperledger Fabric.  To learn more about it check this out: Hyperledger Overview.  Getting Hyperledger Fabric to run on Raspberry Pi presented several major hurdles:

  • No one had compiled the project for the ARM architecture before.
  • There wasn’t any documentation on how to run the Hyperledger on a Docker Swarm.

But hurdles are what make projects fun right? So lets go through the steps so that you can setup your own.

  1. Setting up a Hyperledger Fabric development environment on a Raspberry Pi
  2. Building Hyperledger Fabric on Raspberry Pi
  3. Setting up a Docker Swarm on Raspberry Pi
  4. Deploying a Hyperledger Fabric network on the Swarm with Docker Stack and testing with BYFN.

Lets get started!

Setting up a Hyperledger Fabric development environment on a Raspberry Pi

Setup your Raspi

For this project I used Raspbian Lite (who needs a GUI am I right!) . Download and follow the install guide for your OS on raspberrypi.org.  I originally did this on Jessie but since Stretch is out I’m testing it with the latest build I’m doing while updating my documentation and this series.  So the instructions below apply to Stretch.

Then you’ll need to do some pretty standard initial setup for your RasPi, run raspi-config, change default password, enable SSH, config your keyboard, set the timezone, advanced -> change memory split to 16MB… etc. Once the basic config is done it’s time to get it online.  You can use an ethernet cable or follow this guide to setup wifi.  Also once you have a network connection established use can use SSH, personally I usually do this so I don’t need to “hand jam” all the commands and can just C&P.  You can also copy your private key on your computer to you RasPi so you no longer need a password.  When I do this I usually create a new user:
sudo adduser *username*
sudo usermod -aG sudo *username*

After you do the standard stuff I always recommend updating & upgrading:
sudo apt-get update
sudo apt-get dist-upgrade

Setup your development environment

Install the Go programming language:

Hyperledger was built and tested using Go version 1.7.5… so says the documentation (at time of writing – March 9th, 2018).  I’ve tried using 1.10, 1.9.4, 1.9.3 and 1.8.7 recently and they all had some issues. Go v1.8.7 build suffer form this issue: https://github.com/golang/go/issues/23739.  So I’m going to recommend using Go 1.7.5 since we are targeting a HL v1.0 build.  As I learned you need to make sure you target the correct branch for the build you are targeting.


wget https://dl.google.com/go/go1.7.5.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go1.7.5.linux-armv6l.tar.gz
sudo echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
sudo echo 'export GOPATH=$HOME/go' >> ~/.profile

Install Docker

curl -sSL https://get.docker.com | sh

Install Docker Compose

curl -s https://packagecloud.io/install/repositories/Hypriot/Schatzkiste/script.deb.sh | sudo bash

Install Required Libraries

sudo apt-get install git python-pip python-dev docker-compose build-essential libtool libltdl-dev libssl-dev libevent-dev libffi-dev 

Install Python Libraries

sudo pip install --upgrade pip
sudo pip install --upgrade setuptools
sudo pip install behave nose docker-compose
sudo pip install -I flask==0.10.1 python-dateutil==2.2 pytz==2014.3 pyyaml==3.10 couchdb==1.0 flask-cors==2.0.1 requests==2.4.3 pyOpenSSL==16.2.0 pysha3==1.0b1 grpcio==1.0.4

Reboot & Test

Make sure you actually reboot or re-login to your RasPi otherwise you’ll get nothing from the go version or path (since they were added to your bash profile).

go version
docker -v
docker-compose -v
pip -V
git --version
echo $GOPATH

(should be something like /home/user/go)

All of the above commands should output the version or the required software.  If they do no you missed something.

If you are getting any errors while installing any libraries please reference the current documentation for Hyperledger.

Anyway… now that we have our development environment setup it’s time to start the build.  Check out my next article for the details on this next step.


15 thoughts on “Hyperledger Fabric v1.0 on a Raspberry Pi Docker Swarm – Part 1

  1. Peter Bosch says:

    i came as far as Install Python Libraries
    raspberry pi3 and stretch (with desktop)
    errors encountered..
    -sudo pip install –upgrade pip
    -sudo pip install -I .. 1.0.4

    File “/usr/lib/python2.7/dist-packages/pip/req/req_install.py”, line 82, in __init__
    req = Requirement(req)
    File “/usr/share/python-wheels/packaging-16.8-py2.py3-none-any.whl/packaging/requirements.py”, line 94, in __init__
    requirement_string[e.loc:e.loc + 8]))
    compilation terminated.
    error: command ‘arm-linux-gnueabihf-gcc’ failed with exit status 1

    Command “/usr/bin/python -u -c “import setuptools, tokenize;__file__=’/tmp/pip-build-yuRTRJ/cffi/setup.py’;f=getattr(tokenize, ‘open’, open)(__file__);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, __file__, ‘exec’))” install –record /tmp/pip-ZcQK3q-record/install-record.txt –single-version-externally-managed –compile” failed with error code 1 in /tmp/pip-build-yuRTRJ/cffi/


    1. Joe says:

      I’ll dig back into my build documentation because I don’t remember that issue. I’ll try and publish another article on this soon.

    2. Joe says:

      Found the problem I needed to wrap my code block in the post because the double hyphen was getting converted to a single long one. The post has been updated :D . Thanks for the feedback.

  2. Pete says:

    IBM Oracle SAP are using Hyperledger Fabrik.Banks are deploying it to 8 countries.
    The is now a oracle sandbox .

    Something to explore for me in 2018. !

  3. Bhargav says:

    Great work!!
    Could you please let me know when are you planning to publish the next steps.

  4. Reto says:

    Hi Joe,

    Really interessting article. Did you successfully install hyperledger on the raspberry pi? I would love some more articles about it



    1. Joe says:

      Yes I did and ran a full simulation. I’ve been meaning to do a video and write more about it… but I got pulled into other things. Maybe your interest is just the kick I needed to get back to this. Thanks!

      1. Mohit says:

        Hi joe, I am eagerly waiting for your video. I found this article very interesting

        1. Joe says:

          Thanks Mohit! Well post two is almost finished. The image build has required some finagling since things on the hyperledger end have gotten a bit out of date but it’s coming along.

          1. AP says:

            Hey Joe, your tutorial would prove quite useful for a few of my university projects. Hopefully you will have something in store for us soon!

          2. Pedro says:

            Hey Joe!
            Just did these instructions and all fine so far.
            Planning to deploy part 2 soon?
            Eagerly waiting.

          3. Joe says:

            It’ll be published once I get a successful build and I’m almost there. I have just a few more issues to work out.

  5. satish says:

    Hello jeo,
    Great work bro, I have a question, I installed everything on the Rapsberry pi 3,Docker is running fine for hello-world program, but when i further go for hyperledger network, It gives me error “Error response from daemon: manifest for not found ”
    I tried to solve this issue, Do you have any Idea
    Thanks in advance

    1. Joe says:

      Hmmm… I haven’t experienced that issue myself. What exactly are you trying to do with the network?

      1. satish says:

        I am just trying to run fabric-samples first network, to check everything is fine.

Tell me what you REALLY think...

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

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">