Dapr .NET SDK Development with Docker-Compose

    Consider this to be a .NET companion to the [Dapr Self-Hosted with Docker Guide]({{ ref self-hosted-with-docker.md }})).

    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.

    • 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.

    💡 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 Dockerfile for each service

    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 communiate
    • Each service’s container
    • A sidecar container with the service’s port and app-id specified
    • optional: Dapr placement container (for actors)