Initialize Dapr in your local environment
Fetch the Dapr sidecar binaries and install them locally using dapr init
Now that you’ve installed the Dapr CLI, use the CLI to initialize Dapr on your local machine.
Dapr runs as a sidecar alongside your application. In self-hosted mode, this means it is a process on your local machine. By initializing Dapr, you:
- Fetch and install the Dapr sidecar binaries locally.
- Create a development environment that streamlines application development with Dapr.
Dapr initialization includes:
- 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.
- Running a Dapr scheduler service container instance for job scheduling.
Kubernetes Development Environment
To initialize Dapr in your local or remote Kubernetes cluster for development (including the Redis and Zipkin containers listed above), see how to initialize Dapr for development on Kubernetes
Docker
The recommended development environment requires Docker. While you can initialize Dapr without a dependency on Docker, the next steps in this guide assume the recommended Docker development environment.
You can also install Podman in place of Docker. Read more about initializing Dapr using Podman.
Step 1: Open an elevated terminal
You will need to use sudo
for this quickstart if:
- You run your Docker commands with
sudo
, or - The install path is
/usr/local/bin
(default install path).
Run Windows Terminal or command prompt as administrator.
- Right click on the Windows Terminal or command prompt icon.
- Select Run as administrator.
Step 2: Run the init CLI command
Install the latest Dapr runtime binaries:
dapr init
If you run your Docker cmds with sudo, you need to use:
sudo dapr init
If you are installing on Mac OS Silicon with Docker, you may need to perform the following workaround to enable dapr init
to talk to Docker without using Kubernetes.
- Navigate to Docker Desktop > Settings > Advanced.
- Select the Allow the default Docker socket to be used (requires password) checkbox.
Install the latest Dapr runtime binaries:
dapr init
Expected output:
Step 3: Verify Dapr version
dapr --version
Output:
CLI version: 1.14.1
Runtime version: 1.14.4
Step 4: Verify containers are running
As mentioned earlier, the dapr init
command launches several containers that will help you get started with Dapr. Verify you have container instances with daprio/dapr
, openzipkin/zipkin
, and redis
images running:
docker ps
Output:
Step 5: Verify components directory has been initialized
On dapr init
, the CLI also creates a default components folder that contains several YAML files with definitions for a state store, Pub/sub, and Zipkin. The Dapr sidecar will read these components and use:
- The Redis container for state management and messaging.
- The Zipkin container for collecting traces.
Verify by opening your components directory:
- On Windows, under
%UserProfile%\.dapr
On Linux/MacOS, under
~/.dapr
- Windows
ls $HOME/.dapr
Output:
bin components config.yaml
You can verify using either PowerShell or command line. If using PowerShell, run:
explorer "$env:USERPROFILE\.dapr"
If using command line, run:
explorer "%USERPROFILE%\.dapr"
Result:
Slim init
To install the CLI without any default configuration files or Docker containers, use the --slim
flag. Learn more about the init command and its flags.
dapr init --slim
Next step: Use the Dapr API >>
Last modified October 11, 2024: Fixed typo (#4389) (fe17926)