It’s really, really hot and humid down here in sunny Florida. So, I got my tennis in early this weekend¬†(it was still really hot!) and then settled in for a little experimentation for the rest of the long, hot days. I’ve been wanting¬†to install Docker for Mac (Beta) ever since it was released, but¬†haven’t had the time.

Of course, once I had installed Docker for Mac (Beta), I needed something to do with it. So, I thought I’d see what we needed to do to adapt to running the Hyperledger Fabric.

First thing is that Docker for Mac does not run in, or require, Vagrant; it runs natively using HyperKit. It also doesn’t support routing IP traffic to and from containers. You can, however, expose ports and container linking works just fine.

I was also interested in making Hyperledger Fabric a bit more accessible. The current docs seem to be very much oriented to someone developing the Fabric. Now that we have a release and have published images for the fabric-peer and fabric-membersrvcs to DockerHub, we need to start orienting towards those who simply want to run the Hyperledger Fabric and develop chaincode and blockchain applications.

The current documentation requires that you install the development environment, which is rather involved and somewhat unnecessary for those of you simply seeking to try out the platform and develop an application.

Here’s what you’ll need:

The Hyperledger Fabric project currently only supports writing chaincode in Go, so if you intend to do any chaincode development, you’ll need to install Go – though within the next couple of weeks we hope to have the Java chaincode shim merged, which will open up the ability to use Java.

Create a directory in your development workspace. Next, you’ll need to create a compose file. Take a look at the compose files we have in the Hyperledger Fabric’s¬†integration tests if you’d like to experiment with additional levels of complexity (e.g. more peer nodes, member services, etc). We’ll start with a very simple single node deployment.

Create a docker-compose.yml file and add the following content:

image: hyperledger/fabric-peer
- "5000:5000"
command: peer node start

If you compare this compose file with the others I referenced above, you’ll note two differences:

  1. the CORE_VM_ENDPOINT is set to localhost rather than the Vagrant IP
  2. the ports section which exposes the peer’s container port 5000 on the host

It should be noted that running multiple peers will require that you expose only one peer’s container ports on the host or you’ll have port collisions. However, for developing¬†applications or chaincode on your Mac, a single peer node running the ‘noops’ consensus should be more than adequate for your needs.

You should now be able to start up a peer node using the docker-compose up command. Give it a try. Running docker ps should return something like the following:

docker ps
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS              PORTS                    NAMES
c1ada03e6c40        hyperledger/fabric-peer   "peer node start"   15 hours ago        Up 26 seconds>5000/tcp   hlp_vp_1

You should now be able to interact with your peer. It isn’t running PBFT consensus, but for purposes of development, that shouldn’t be necessary. It is also running without the membersrvc service which means security is disabled. If you want to have both services running, add the following to your docker-compose.yml, and rerun docker-compose up:

  image: hyperledger/fabric-membersrvc
  command: membersrvc

There are a few ways to start interacting with your peer, but now that you have a peer up and running, you should be able to bypass creating a Hyperledger Fabric development environment and get right to the process of writing chaincode or leveraging the Node SDK to write an application.

10 comments on"Running Hyperledger Fabric Natively on Mac"

  1. benjamin fuentes July 08, 2016

    YES YES and YES to this => “Now that we have a release and have published images for the fabric-peer and fabric-membersrvcs to DockerHub, we need to start orienting towards those who simply want to run the Hyperledger Fabric and develop chaincode and blockchain applications.”

    +Java integration

    • Christopher Ferris July 08, 2016

      Javascript is another that is in high demand. I am sure it won’t be long. Pull requests always welcome;-)

  2. benjamin fuentes July 08, 2016

    Well, do not forget Javascript too …

  3. Any idea about this kind of error while trying to deploy/query or invoke ?

    vp1_1 | 15:32:16.169 [dockercontroller] Start -> ERRO 05f start-could not recreate container cannot connect to Docker endpoint

  4. Quick one … what purpose does the image hyperledger/fabric-base server? Also, once the peer and the member images are running, what steps do I need to follow to replicate the marbles demo?

    • Hi, did you get the details how to deploy demo after deploying peer and member images using docker? I am also looking for this information and didn’t find one.

  5. After I run “docer-compose up”, the error is
    “ERROR: yaml.scanner.ScannerError: while scanning a simple key
    in “./docker-compose.yml”, line 2, column 1
    could not found expected ‘:’
    in “./docker-compose.yml”, line 3, column 1″
    How can I do?

    • benjamin fuentes November 30, 2016

      Correct your yaml syntax first
      i am sure the structure is not correct , due to copy/pasta

  6. I’m seeing errors from the behave tests when running ‘make dist-clean all’ on OS/X Sierra (10.12.3)

    Where would be the appropriate place to ask about this please?

Join The Discussion

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