Fix self-hosted docs

This commit is contained in:
Aaron Crawfis 2021-04-28 12:03:06 -07:00
parent 8ff1c14743
commit 046504660b
3 changed files with 92 additions and 47 deletions

View File

@ -3,15 +3,30 @@ type: docs
title: "Overview of Dapr in self-hosted mode"
linkTitle: "Overview"
weight: 10000
description: "Overview of how to get Dapr running on your local machine"
description: "Overview of how to get Dapr running on a Windows/Linux/MacOS machine"
---
Dapr can be configured to run on your local developer machine in self hosted mode. Each running service has a Dapr runtime process (or sidecar) which is configured to use state stores, pub/sub, binding components and the other building blocks.
## Overview
In self hosted mode, Redis is running locally in a container and is configured to serve as both the default component for state store and for pub/sub. A Zipkin container is also configured for diagnostics and tracing. After running `dapr init`, see the `$HOME/.dapr/components` directory (Mac/Linux) or `%USERPROFILE%\.dapr\components` on Windows.
Dapr can be configured to run in self-hosted mode on your local developer machine or on production VMs. Each running service has a Dapr runtime process (or sidecar) which is configured to use state stores, pub/sub, binding components and the other building blocks.
The `dapr-placement` service is responsible for managing the actor distribution scheme and key range settings. This service is only required if you are using Dapr actors. For more information on the actor `Placement` service read [actor overview]({{< ref "actors-overview.md" >}}).
## Initialization
<img src="/images/overview_standalone.png" width=800>
Dapr can be initialized [with Docker]({{< ref self-hosted-with-docker.md >}}) (default) or in [slim-init mode]({{< ref self-hosted-no-docker.md >}}). The default Docker setup provides out of the box functionality with the following containers and configuration:
- A Redis container configured to serve as the default component for both state management and publish/subscribe.
- A Zipkin container for diagnostics and tracing.
- A default Dapr configuration and components installed in `$HOME/.dapr/` (Mac/Linux) or `%USERPROFILE%\.dapr\` (Windows).
You can use the [Dapr CLI](https://github.com/dapr/cli#launch-dapr-and-your-app) to run a Dapr enabled application on your local machine.
The `dapr-placement` service is responsible for managing the actor distribution scheme and key range settings. This service is not launched as a container and is only required if you are using Dapr actors. For more information on the actor `Placement` service read [actor overview]({{< ref "actors-overview.md" >}}).
<img src="/images/overview-standalone-docker.png" width=1000 alt="Diagram of Dapr in self-hosted Docker mode" />
## Launching applications with Dapr
You can use the [`dapr run` CLI command]({{< ref dapr-run.md >}}) to a Dapr sidecar process along with your application.
## Name resolution
Dapr uses a [name resolution component]({{< ref supported-name-resolution >}}) for service discovery within the [service invocation]({{< ref service-invocation >}}) building block. By default Dapr uses mDNS when in self-hosted mode.
If you are running Dapr on virtual machines or across multiple machines you can use [HashiCorp Consul]({{< ref setup-nr-consul.md >}}).

View File

@ -6,58 +6,59 @@ weight: 20000
description: "How to deploy and run Dapr in self-hosted mode using Docker"
---
This article provides guidance on running Dapr with Docker outside of Kubernetes. There are a number of different configurations in which you may wish to run Dapr with Docker that are documented below.
This article provides guidance on running Dapr with Docker on a Windows/Linux/macOS machine or VM.
## Prerequisites
- [Dapr CLI]({{< ref install-dapr-cli.md >}})
- [Docker](https://docs.docker.com/get-docker/)
- [Docker-Compose](https://docs.docker.com/compose/install/) (optional)
## Select a Docker image
Dapr provides a number of prebuilt Docker images for different components, you should select the relevant image for your desired binary, architecture, and tag/version.
## Initialize Dapr environment
### Images
There are published Docker images for each of the Dapr components available on [Docker Hub](https://hub.docker.com/u/daprio).
- [daprio/dapr](https://hub.docker.com/r/daprio/dapr) (contains all Dapr binaries)
- [daprio/daprd](https://hub.docker.com/r/daprio/daprd)
- [daprio/placement](https://hub.docker.com/r/daprio/placement)
- [daprio/sentry](https://hub.docker.com/r/daprio/sentry)
- [daprio/dapr-dev](https://hub.docker.com/r/daprio/dapr-dev)
To initialize the Dapr control-plane containers and create a default configuration file, run:
### Tags
#### Linux/amd64
- `latest`: The latest release version, **ONLY** use for development purposes.
- `edge`: The latest edge build (master).
- `major.minor.patch`: A release version.
- `major.minor.patch-rc.iteration`: A release candidate.
#### Linux/arm/v7
- `latest-arm`: The latest release version for ARM, **ONLY** use for development purposes.
- `edge-arm`: The latest edge build for ARM (master).
- `major.minor.patch-arm`: A release version for ARM.
- `major.minor.patch-rc.iteration-arm`: A release candidate for ARM.
```bash
dapr init
```
## Run app as a process
> For development purposes ONLY
## Run both app and sidecar as a process
The [`dapr run` CLI command]({{< ref dapr-run.md >}}) can be used to launch a Dapr sidecar along with your application:
```bash
dapr run --app-id myapp --app-port 5000 -- dotnet run
```
This command will launch both the daprd sidecar binary and run `dotnet run`, launching your application.
## Run app as a process and sidecar as a Docker container
Alternately, if you are running Dapr in a Docker container and your app as a process on the host machine, then you need to configure Docker to use the host network so that Dapr and the app can share a localhost network interface.
{{% alert title="Note" color="warning" %}}
The host networking driver for Docker is only supported on Linux hosts.
{{% /alert %}}
If you are running your Docker daemon on a Linux host, you can run the following to launch Dapr:
If you are running Dapr in a Docker container and your app as a process on the host machine, then you need to configure
Docker to use the host network so that Dapr and the app can share a localhost network interface. Unfortunately, the host networking driver for Docker is only supported on Linux hosts.
If you are running your Docker daemon on a Linux host, you should be able to run the following to launch Dapr.
```shell
docker run --net="host" --mount type=bind,source="$(pwd)"/components,target=/components daprio/daprd:edge ./daprd -app-id <my-app-id> -app-port <my-app-port>
```
Then you can run your app on the host and they should connect over the localhost network interface.
However, if you are not running your Docker daemon on a Linux host, it is recommended you follow the steps below to run
both your app and the [Dapr runtime in Docker containers using Docker Compose](#run-dapr-in-a-docker-container-using-docker-compose).
## Run app and Dapr in a single Docker container
## Run both app and Dapr in a single Docker container
> For development purposes ONLY
It is not recommended to run both the Dapr runtime and an application inside the same container. However, it is possible to do so for local development scenarios.
In order to do this, you'll need to write a Dockerfile that installs the Dapr runtime, Dapr CLI and your app code.
You can then invoke both the Dapr runtime and your app code using the Dapr CLI.
Below is an example of a Dockerfile which achieves this:
```
```docker
FROM python:3.7.1
# Install dapr CLI
RUN wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
@ -79,23 +80,24 @@ Remember that if Dapr needs to communicate with other components i.e. Redis, the
be made accessible to it.
## Run on a Docker network
If you have multiple instances of Dapr running in Docker containers and want them to be able to
communicate with each other i.e. for service invocation, then you'll need to create a shared Docker network
communicate with each other *i.e. for service invocation*, then you'll need to create a shared Docker network
and make sure those Dapr containers are attached to it.
You can create a simple Docker network using
```
You can create a simple Docker network using:
```bash
docker network create my-dapr-network
```
When running your Docker containers, you can attach them to the network using
```
When running your Docker containers, you can attach them to the network using:
```bash
docker run --net=my-dapr-network ...
```
Each container will receive a unique IP on that network and be able to communicate with other containers on that network.
## Run using Docker-Compose
[Docker Compose](https://docs.docker.com/compose/) can be used to define multi-container application
configurations. If you wish to run multiple apps with Dapr sidecars locally without Kubernetes then it is recommended to use a Docker Compose definition (`docker-compose.yml`).
[Docker Compose](https://docs.docker.com/compose/) can be used to define multi-container application configurations. If you wish to run multiple apps with Dapr sidecars locally without Kubernetes then it is recommended to use a Docker Compose definition (`docker-compose.yml`).
The syntax and tooling of Docker Compose is outside the scope of this article, however, it is recommended you refer to the [offical Docker documentation](https://docs.docker.com/compose/) for further details.
@ -143,7 +145,35 @@ services:
To further learn how to run Dapr with Docker Compose, see the [Docker-Compose Sample](https://github.com/dapr/samples/tree/master/hello-docker-compose).
## Run on Kubernetes
If your deployment target is Kubernetes then you're probably better of running your applicaiton and Dapr sidecars directly on
a Kubernetes platform. Running Dapr on Kubernetes is a first class experience and is documented separately. Please refer to the
[Dapr on Kubernetes docs]({{< ref "kubernetes-overview.md" >}})
If your deployment target is Kubernetes please use Dapr's first-class integration. Refer to the
[Dapr on Kubernetes docs]({{< ref "kubernetes-overview.md" >}}).
## Name resolution
Dapr by default uses mDNS as the name resolution component in self-hosted mode for service invocation. If running on multiple machines and/or VMs, visit the [supported name resolution providers page]({{< ref supported-name-resolution. >}}) to pick an alternate provider.
## Docker images
Dapr provides a number of prebuilt Docker images for different components, you should select the relevant image for your desired binary, architecture, and tag/version.
### Images
There are published Docker images for each of the Dapr components available on [Docker Hub](https://hub.docker.com/u/daprio).
- [daprio/dapr](https://hub.docker.com/r/daprio/dapr) (contains all Dapr binaries)
- [daprio/daprd](https://hub.docker.com/r/daprio/daprd)
- [daprio/placement](https://hub.docker.com/r/daprio/placement)
- [daprio/sentry](https://hub.docker.com/r/daprio/sentry)
- [daprio/dapr-dev](https://hub.docker.com/r/daprio/dapr-dev)
### Tags
#### Linux/amd64
- `latest`: The latest release version, **ONLY** use for development purposes.
- `edge`: The latest edge build (master).
- `major.minor.patch`: A release version.
- `major.minor.patch-rc.iteration`: A release candidate.
#### Linux/arm/v7
- `latest-arm`: The latest release version for ARM, **ONLY** use for development purposes.
- `edge-arm`: The latest edge build for ARM (master).
- `major.minor.patch-arm`: A release version for ARM.
- `major.minor.patch-rc.iteration-arm`: A release candidate for ARM.

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 KiB