The documentation you are viewing is for Dapr v1.10 which is an older version of Dapr. For up-to-date documentation, see the latest version.
Dapr .NET SDK Development with Docker-Compose
Docker-Compose
Consider this to be a .NET companion to the Dapr Self-Hosted with Docker Guide.
docker-compose is a CLI tool included with Docker Desktop that you can use to run multiple containers at a time. It is a way to automate the lifecycle of multiple containers together, and offers a development experience similar to a production environment for applications targeting Kubernetes.
- Pro: Since
docker-composemanages containers for you, you can make dependencies part of the application definition and stop the long-running containers on your machine. - Con: most investment required, services need to be containerized to get started.
- Con: can be difficult to debug and troubleshoot if you are unfamilar with Docker.
Using docker-compose
From the .NET perspective, there is no specialized guidance needed for docker-compose with Dapr. docker-compose runs containers, and once your service is in a container, configuring it similar to any other programming technology.
💡 App Port
In a container, an ASP.NET Core app will listen on port 80 by default. Remember this for when you need to configure the--app-port later.
To summarize the approach:
- Create a
Dockerfilefor each service - Create a
docker-compose.yamland place check it in to the source code repository
To understand the authoring the docker-compose.yaml you should start with the Hello, docker-compose sample.
Similar to running locally with dapr run for each service you need to choose a unique app-id. Choosing the container name as the app-id will make this simple to remember.
The compose file will contain at a minimum:
- A network that the containers use to communicate
- Each service’s container
- A
<service>-daprdsidecar container with the service’s port and app-id specified - Additional dependencies that run in containers (redis for example)
- optional: Dapr placement container (for actors)
You can also view a larger example from the eShopOnContainers sample application.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.