Setup a Hyperledger Fabric Host and Create a Machine Image


During the training and testing on Hyperledger Fabric networks and chaincodes, I always need a “standard” host running Hyperledger Fabric. By “standard” it is nothing more than a Ubuntu host with prerequisite components (link) and Hyperledger Fabric images, tools and samples (link). They are well documented in Hyperledger Fabric documentation.

Launch an EC2 Instance

Here we first select Ubuntu Server 18.04 LTS (HVM). It is the base we are going to install all components later.

Install Prerequisite components for Hyperledger Fabric

The prerequisite components for Hyperledger Fabric host is shown here. In summary we are installing the following:

  • docker and docker compose
  • Go programming language
  • Node.js runtime and NPM
  • Python
ssh -i <key> ubuntu@<public_ip>
sudo apt-get update

Install cURL

Install or update the curl.

sudo apt install curl

Install docker and docker-compose

While you can follow the standard way to install, I use the following command and it can install both docker and docker-compose good for our use.

sudo apt-get -y install docker-compose
sudo usermod -aG docker $USER
docker -v
docker-compose -v

Install Go Programming Language

Here we use version 1.11.11

sudo tar -xvf go1.11.11.linux-amd64.tar.gz
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Install Node.js and NPM

Per suggestion we are installing node.js version 8.x.

curl -sL | sudo bash -
sudo apt install nodejs
node -v
npm -v

Install Python

Ubuntu 18.02 comes with proper installation of python 2.7.

Install Hyperledger Fabric Components

The Hyperledger Fabric components we are going to install are

  • Hyperledger Fabric binary tools
  • Fabric Samples


It is quite straightforward to install all these components with this command.

curl -sSL | bash -s 1.4.1


To see whether the installation is complete, we check the three portions.

docker images
cd fabric-samples/first-network
./ up
./ downexit

Create an AMI on this Host

We are done with our software installation. Now we go back to AWS console and create an AMI with this host.

Launch an EC2 instance with our AMI

Now we first terminate our own instance (yes, to save money).

// should have no running containers
docker ps
// hyperledger fabric docker images are all there
docker images
cd fabric-samples/first-network// wait till whole script complete
./ up
// tear down the first network and chaincode
./ down


This article showed a simple way to create a machine image for fast preparation of a Hyperledger Fabric host. We first walked through the installation of the prerequisite components and Hyperledger Fabric components on a Ubuntu host. Then we made a machine image (AMI here as I am using AWS). Finally a new EC2 instance can be launched with this AMI without installing things from the scratch again.

Visit for all my works. Reach me on or follow me @kctheservant in Twitter.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store