Learning Dapr Part 1: Install and Initialize Dapr on MacOS

In this tutorial, you will learn how to install Dapr CLI and initialize Dapr in your local environment.

Dapr is Distributed Application Runtime. It is an open source, portable, event-driven runtime that makes it easy for any developer to build resilient, microservice stateless and stateful applications that run on the cloud and edge. Dapr embraces the diversity of languages and developer frameworks and simplified building application block.

Install The Dapr CLI

It is recommended to install Dapr CLI using Homebrew on MacOS:

$ brew install dapr/tap/dapr-cli

Using dapr command to verify the installation:

$ dapr

the output should look like this if the Dapr CLI been installed successfully.

You can also use dapr --version command, which will show Dapr CI version and Dapr Runtime version.

Please note that, the Runtime version should be n/a before initializing local environment. Above screenshot shows 1.0.1 which means the environment already done the initialization.

Initialize Dapr in local environment

Dapr runs as a sidecar alongside your application, and in self-hosted mode this means it is a process on your local machine.
Therefore, initializing Dapr includes fetching the Dapr sidecar binaries and installing them locally.

The default initialization process also creates a development environment that helps streamline application development with Dapr.
This includes the following steps:

  • Running a Redis container instance to be used as a local state store and message broker
  • Running a Zipkin container instance for observability
  • Creating a default components folder with component definitions for the above
  • Running a Dapr placement service container instance for local actor support

Step 1 – Install Docker

You can download Docker Desktop for Mac from Docker Hub: Download Address.

Your Mac must meet the following requirements to successfully install Docker Desktop:

  • MacOS must be version 10.14 or newer.
  • At least 4 GB of RAM.
  • VirtualBox prior to version 4.3.30 must not be installed as it is not compatible with Docker Desktop.

For docker for Mac installation detail, refer to official guide: https://docs.docker.com/docker-for-mac/install/

Step 2 – Run Init CLI Command

$ dapr init

Will get following error if the docker service is not start up.

❌  could not connect to Docker. Docker may not be installed or running.

Will get following output if everything goes well.

✅  Downloaded binaries and completed components set up.
ℹ️  daprd binary has been installed to /Users/zclmoon/.dapr/bin.
ℹ️  dapr_placement container is running.
ℹ️  dapr_redis container is running.
ℹ️  dapr_zipkin container is running.
ℹ️  Use `docker ps` to check running containers.
✅  Success! Dapr is up and running. To get started, go here: https://aka.ms/dapr-getting-started

Step 3 – Verify Version

Run command dapr --version again, will find that there are version no of Runtime version, it was n/a before initialization.

Step 4 – Verify Docker Container Instance

Run following command, and make sure that instances with daprio/dapropenzipkin/zipkin, and redis images are all running:

$ docker ps

Step 5 – Verify Initialized Components Folder

On dapr init, the CLI also creates a default components folder which includes several YAML files with definitions for a state store, pub/sub and zipkin. These will be read by the Dapr sidecar, telling it to use the Redis container for state management and messaging and the Zipkin container for collecting traces.

$ ls ~/.dapr/

And the output should be as following if all are good.

(base)zclmoon$ ls ~/.dapr/
bin		components	config.yaml

Step 6 – Start Dapr Dashboard locally

Use following command to start up Dapr dashboard locally, and set its port to 9000:

$ dapr dashboard -p 9000


In this tutorial, we have learned that how to install Dapr CLI and initialize Dapr in local environment.

One Reply to “Learning Dapr Part 1: Install and Initialize Dapr on MacOS”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.