# testcontainers/testcontainers-dotnet

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/testcontainers-testcontainers-dotnet).**

4,317 stars · 348 forks · C# · MIT

## Links

- GitHub: https://github.com/testcontainers/testcontainers-dotnet
- Homepage: https://dotnet.testcontainers.org
- awesome-repositories: https://awesome-repositories.com/repository/testcontainers-testcontainers-dotnet.md

## Topics

`automation` `docker` `dotnet` `hacktoberfest` `testcontainers` `testcontainers-dotnet` `testing`

## Description

Testcontainers for .NET is a Docker testing library and integration testing framework designed to manage the lifecycle of throwaway containers. It provides high-level abstractions as a Docker API wrapper to provision ephemeral infrastructure, replacing mocks with real database, messaging, and search engine instances to ensure isolated and reproducible test environments.

The project distinguishes itself through a builder-configuration-container pattern and a dynamic port binding mechanism that prevents collisions during concurrent test execution. It enables reliable service-to-service communication via virtual network orchestration and network aliasing, and ensures service availability through polling-based readiness checks for HTTP endpoints and TCP ports.

The library provides specialized modules for relational, NoSQL, and vector databases, as well as messaging brokers and cloud service emulators. Its capability surface extends to container image configuration, log collection, and the simulation of network conditions to verify system resiliency.

It supports connectivity to both local and remote Docker runtimes through standardized environment variables and configuration files.

## Tags

### DevOps & Infrastructure

- [Automated Testing Containers](https://awesome-repositories.com/f/devops-infrastructure/container-orchestration/container-runtimes/runtime-configuration-interfaces/docker-socket-orchestrators/docker-target-configurators/docker-container-deployments/docker-container-execution/automated-testing-containers.md) — Creates and destroys isolated containers specifically for the automated test lifecycle across different operating systems. ([source](https://cdn.jsdelivr.net/gh/testcontainers/testcontainers-dotnet@develop/README.md))
- [Database Containers](https://awesome-repositories.com/f/devops-infrastructure/container-instance-management/database-containers.md) — Creates and starts disposable Db2 container instances for isolated database testing. ([source](https://dotnet.testcontainers.org/modules/db2/))
- [Test Database Provisioning](https://awesome-repositories.com/f/devops-infrastructure/container-instance-management/database-containers/test-database-provisioning.md) — Provides automated deployment of database containers specifically tailored for development and integration testing environments. ([source](https://dotnet.testcontainers.org/test_frameworks/xunit_net/))
- [Container Lifecycle Management](https://awesome-repositories.com/f/devops-infrastructure/container-orchestration/container-runtimes/runtime-configuration-interfaces/docker-socket-orchestrators/docker-target-configurators/docker-container-deployments/container-lifecycle-management.md) — Manages the full lifecycle of creating, configuring, and cleaning up Docker containers during test suite execution.
- [Valkey Support](https://awesome-repositories.com/f/devops-infrastructure/container-orchestration/container-runtimes/runtime-configuration-interfaces/docker-socket-orchestrators/docker-target-configurators/docker-container-deployments/docker-container-execution/automated-testing-containers/valkey-support.md) — Deploys Redis-compatible Valkey in-memory data stores in containers to provide clean environments for automated tests. ([source](https://dotnet.testcontainers.org/modules/valkey/))
- [Orphaned Container Cleanup](https://awesome-repositories.com/f/devops-infrastructure/container-orchestrators/orphaned-container-cleanup.md) — Automatically identifies and removes orphaned containers and resources after test execution to prevent environment clutter. ([source](https://dotnet.testcontainers.org/api/resource_reaper/))
- [Ephemeral Container Cleanup](https://awesome-repositories.com/f/devops-infrastructure/container-orchestrators/orphaned-container-cleanup/network-resource-cleanups/ephemeral-container-cleanup.md) — Automatically removes temporary containers and virtual networks after test completion to prevent resource leaks.
- [Docker Engine API Clients](https://awesome-repositories.com/f/devops-infrastructure/docker-engine-api-clients.md) — Acts as a high-level SDK providing programmatic interfaces to interact with the Docker Engine API for container management.
- [Ephemeral Service Provisioning](https://awesome-repositories.com/f/devops-infrastructure/ephemeral-database-provisioning/ephemeral-service-provisioning.md) — Provides automatic creation and destruction of temporary containerized services to ensure isolated integration test environments.
- [Runtime Connectivity](https://awesome-repositories.com/f/devops-infrastructure/runtime-connectivity.md) — Handles connectivity to local Docker daemons or remote container runtimes via standardized configurations. ([source](https://dotnet.testcontainers.org/))
- [Service Readiness Checks](https://awesome-repositories.com/f/devops-infrastructure/service-readiness-checks.md) — Repeatedly queries HTTP endpoints or TCP ports to ensure services are fully initialized before proceeding with tests.
- [CI/CD Pipeline Integrations](https://awesome-repositories.com/f/devops-infrastructure/ci-cd-pipeline-integrations.md) — Integrates with container-hosting runners in pipeline tools to automate the lifecycle of test dependencies. ([source](https://dotnet.testcontainers.org/cicd/))
- [Azure Service Bus Emulators](https://awesome-repositories.com/f/devops-infrastructure/cloud-service-emulators/azure-service-bus-emulators.md) — Starts a local messaging emulator in a container to verify asynchronous communication code without cloud connectivity. ([source](https://dotnet.testcontainers.org/modules/servicebus/))
- [Event Hubs Emulators](https://awesome-repositories.com/f/devops-infrastructure/cloud-service-emulators/event-hubs-emulators.md) — Starts a local containerized instance of an event streaming service to test code in isolation from the cloud. ([source](https://dotnet.testcontainers.org/modules/eventhubs/))
- [Container Environment Variable Injection](https://awesome-repositories.com/f/devops-infrastructure/cluster-environment-automation/centralized-environment-management/container-environment-variable-injection.md) — Configures container environments by setting variables and mapping local files or host directories. ([source](https://dotnet.testcontainers.org/api/create_docker_container/))
- [Container CI/CD Pipelines](https://awesome-repositories.com/f/devops-infrastructure/container-ci-cd-pipelines.md) — Integrates container-based dependencies into automated pipelines to run tests without relying on shared external infrastructure.
- [Container Image Building](https://awesome-repositories.com/f/devops-infrastructure/container-image-building.md) — Creates container images from a Dockerfile by specifying the build context and directory. ([source](https://dotnet.testcontainers.org/api/create_docker_image/))
- [Container Image Configurations](https://awesome-repositories.com/f/devops-infrastructure/container-image-configurations.md) — Specifies the container image to use, including support for specific platforms and architecture resolution. ([source](https://dotnet.testcontainers.org/api/create_docker_container/))
- [Container Reuse Strategies](https://awesome-repositories.com/f/devops-infrastructure/container-image-tagging/container-reuse-strategies.md) — Identifies and attaches to existing containers based on configuration to avoid redundant startup costs between test runs. ([source](https://dotnet.testcontainers.org/api/resource_reuse/))
- [Container Network Attachments](https://awesome-repositories.com/f/devops-infrastructure/infrastructure/networking/routing/network-virtualization-tools/network-namespace-virtualization/container-network-attachments.md) — Allows attaching existing containers to virtual networks to enable communication between disparate resources. ([source](https://dotnet.testcontainers.org/api/create_docker_network/))
- [Virtual Network Isolations](https://awesome-repositories.com/f/devops-infrastructure/virtual-network-isolations.md) — Creates private network bridges to enable isolated service-to-service communication via aliases.

### System Administration & Monitoring

- [Container Lifecycle Management](https://awesome-repositories.com/f/system-administration-monitoring/container-lifecycle-management.md) — Provides a comprehensive framework for managing the full lifecycle of containers, including creation, networking, and cleanup. ([source](https://dotnet.testcontainers.org/api/create_docker_container/))
- [Container Health Monitors](https://awesome-repositories.com/f/system-administration-monitoring/cluster-health-monitoring/container-health-monitors.md) — Monitors the internal health status of containers and pauses execution until they are ready. ([source](https://dotnet.testcontainers.org/api/wait_strategies/))
- [Container Log Retrieval](https://awesome-repositories.com/f/system-administration-monitoring/monitoring-and-observability/observability-platforms/log-management-systems/log-management-services/container-log-retrieval.md) — Provides utilities to fetch and stream logs from running containers for debugging and verification. ([source](https://dotnet.testcontainers.org/api/create_docker_container/))

### Testing & Quality Assurance

- [Docker Integration Testing Libraries](https://awesome-repositories.com/f/testing-quality-assurance/docker-integration-testing-libraries.md) — Provides a library that automates the lifecycle of Docker containers to create isolated environments for integration tests.
- [Test Isolation](https://awesome-repositories.com/f/testing-quality-assurance/general-testing-utilities/test-isolation.md) — Ensures total environment isolation by creating a fresh, disposable container for every individual test. ([source](https://dotnet.testcontainers.org/test_frameworks/xunit_net/))
- [Integration Testing Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/e2e-integration-testing/integration-testing-frameworks.md) — Provides a framework to provision real database, messaging, and search engine containers to replace mocks in integration tests.
- [Browser Automation](https://awesome-repositories.com/f/testing-quality-assurance/automation-interaction-tools/browser-automation.md) — Deploys pre-configured browser instances for executing automated web tests in isolation. ([source](https://dotnet.testcontainers.org/modules/playwright/))
- [Readiness Checks](https://awesome-repositories.com/f/testing-quality-assurance/http-endpoint-simulation/readiness-checks.md) — Implements polling-based readiness checks for HTTP endpoints to ensure services are fully initialized before tests proceed. ([source](https://dotnet.testcontainers.org/api/wait_strategies/))
- [Network Condition Simulation](https://awesome-repositories.com/f/testing-quality-assurance/network-condition-simulation.md) — Simulates network conditions by injecting latency, timeouts, and bandwidth limits to verify system resiliency. ([source](https://dotnet.testcontainers.org/modules/toxiproxy/))

### Part of an Awesome List

- [Containerized Database Integration](https://awesome-repositories.com/f/awesome-lists/devtools/database-testing/containerized-database-integration.md) — Provisions disposable relational, NoSQL, or vector database instances in Docker to verify data persistence and query logic.
- [Testing Frameworks](https://awesome-repositories.com/f/awesome-lists/devtools/testing-frameworks.md) — Library for running tests with throwaway Docker containers.

### Data & Databases

- [Containerized Instances](https://awesome-repositories.com/f/data-databases/cassandra-compatible-databases/containerized-instances.md) — Starts and manages temporary Apache Cassandra database instances for use in automated tests. ([source](https://dotnet.testcontainers.org/modules/cassandra/))
- [Containerized Instances](https://awesome-repositories.com/f/data-databases/database-connectivity/clickhouse-connectors/containerized-instances.md) — Starts and stops column-oriented ClickHouse SQL database instances as throwaway containers for isolated tests. ([source](https://dotnet.testcontainers.org/modules/clickhouse/))
- [Containerized Instances](https://awesome-repositories.com/f/data-databases/mongodb-integrations/containerized-instances.md) — Deploys MongoDB database containers with custom authentication and replica settings for isolated testing. ([source](https://dotnet.testcontainers.org/modules/mongodb/))
- [Containerized Instances](https://awesome-repositories.com/f/data-databases/postgresql-database-platforms/containerized-instances.md) — Starts throwaway PostgreSQL database instances with specific versions and configurations for isolated test environments. ([source](https://dotnet.testcontainers.org/modules/postgres/))
- [Redis Provisioners](https://awesome-repositories.com/f/data-databases/redis-deployment-tools/redis-provisioners.md) — Manages the lifecycle of Redis instances by starting and removing throwaway containers for in-memory data storage. ([source](https://dotnet.testcontainers.org/modules/garnet/))
- [Elasticsearch Containers](https://awesome-repositories.com/f/data-databases/elasticsearch-containers.md) — Starts distributed Elasticsearch search and analytics engines in containers with support for HTTPS and passwords. ([source](https://dotnet.testcontainers.org/modules/elasticsearch/))
- [Qdrant Integrations](https://awesome-repositories.com/f/data-databases/in-memory-data-stores/vector-stores/qdrant-integrations.md) — Manages the lifecycle of Qdrant vector database containers and provides API connection strings. ([source](https://dotnet.testcontainers.org/modules/qdrant/))
- [MongoDB Script Execution](https://awesome-repositories.com/f/data-databases/mongodb-script-execution.md) — Executes custom scripts inside a MongoDB database container and captures the exit code and output to verify state. ([source](https://dotnet.testcontainers.org/modules/mongodb/))
- [OpenSearch Containers](https://awesome-repositories.com/f/data-databases/opensearch-containers.md) — Spins up isolated OpenSearch instances with configurable security settings for automated tests. ([source](https://dotnet.testcontainers.org/modules/opensearch/))
- [SQL Script Execution](https://awesome-repositories.com/f/data-databases/sql-script-execution.md) — Runs SQL commands directly inside a Db2 container and captures execution results and error output. ([source](https://dotnet.testcontainers.org/modules/db2/))

### Development Tools & Productivity

- [Service Endpoint Retrieval](https://awesome-repositories.com/f/development-tools-productivity/service-endpoint-retrieval.md) — Extracts broker and HTTP URLs from running containers to connect client applications to the active instance. ([source](https://dotnet.testcontainers.org/modules/pulsar/))
- [Cloud Service Emulators](https://awesome-repositories.com/f/development-tools-productivity/development-environment-management/cloud-service-emulation-interception/cloud-infrastructure-emulation/cloud-service-emulators.md) — Runs containerized versions of cloud services locally to enable development and testing in isolation from the cloud.
- [Startup Arguments](https://awesome-repositories.com/f/development-tools-productivity/startup-configurations/startup-script-bypass/terminal-startup-scripts/container-startup-scripts/startup-arguments.md) — Defines or overrides the entrypoint and command arguments that the container executes upon starting. ([source](https://dotnet.testcontainers.org/api/create_docker_container/))
- [Version Pinning](https://awesome-repositories.com/f/development-tools-productivity/versioned-package-managers/version-pinning.md) — Overrides default image tags to specific versions to ensure consistent and reproducible test environments. ([source](https://dotnet.testcontainers.org/api/best_practices/))

### Networking & Communication

- [Container Connection Resolution](https://awesome-repositories.com/f/networking-communication/container-connection-resolution.md) — Provides automatic resolution of network addresses and API endpoints for containers to ensure reliable communication during integration tests. ([source](https://dotnet.testcontainers.org/api/connection_string_provider/))
- [Container Networking Configurations](https://awesome-repositories.com/f/networking-communication/container-networking-configurations.md) — Provides capabilities to create and manage isolated virtual networks for multi-container communication. ([source](https://dotnet.testcontainers.org/examples/aspnet/))
- [Container Port Mapping](https://awesome-repositories.com/f/networking-communication/container-port-mapping.md) — Binds internal container ports to random available host ports to expose services to the test host. ([source](https://dotnet.testcontainers.org/api/create_docker_network/))
- [Dynamic Port Binding](https://awesome-repositories.com/f/networking-communication/container-port-mapping/dynamic-port-binding.md) — Binds container ports to random available host ports to prevent collisions between concurrent test executions. ([source](https://dotnet.testcontainers.org/api/best_practices/))
- [Dynamic Port Listeners](https://awesome-repositories.com/f/networking-communication/network-port-configuration/port-sharing-mechanisms/dynamic-port-listeners.md) — Maps container ports to random available host ports to prevent collisions during concurrent test execution.
- [Port Readiness Verification](https://awesome-repositories.com/f/networking-communication/port-reachability-testing/port-readiness-verification.md) — Monitors TCP ports and blocks test execution until the port is open and accepting incoming connections. ([source](https://dotnet.testcontainers.org/api/wait_strategies/))

### Operating Systems & Systems Programming

- [Container Network Linking](https://awesome-repositories.com/f/operating-systems-systems-programming/virtualization-emulation/virtualization-platforms/virtualization-networking/container-network-linking.md) — Connects multiple containers via a shared virtual network to enable communication between applications and test browsers. ([source](https://dotnet.testcontainers.org/modules/playwright/))
- [Virtual Network Creation](https://awesome-repositories.com/f/operating-systems-systems-programming/virtualization-emulation/virtualization-platforms/virtualization-networking/virtual-network-creation.md) — Sets up isolated virtual networks and assigns containers to them for communication via aliases without exposing ports. ([source](https://dotnet.testcontainers.org/api/create_docker_network/))

### Software Engineering & Architecture

- [Configuration Injection](https://awesome-repositories.com/f/software-engineering-architecture/application-lifecycle-management/configuration-management/environment-variable-management/environment-variable-injection/configuration-injection.md) — Maps dynamic connection strings and environment variables into application configurations for integration testing. ([source](https://dotnet.testcontainers.org/examples/aspnet/))
- [Specialized Container Modules](https://awesome-repositories.com/f/software-engineering-architecture/specialized-container-modules.md) — Wraps generic container logic into specialized modules for specific databases and messaging systems to simplify setup.
- [Container Instance Sharing](https://awesome-repositories.com/f/software-engineering-architecture/context-sharing/shared-test-contexts/container-instance-sharing.md) — Maintains a single container instance for multiple test classes to reduce startup overhead. ([source](https://dotnet.testcontainers.org/test_frameworks/xunit_net/))
- [Builder Patterns](https://awesome-repositories.com/f/software-engineering-architecture/creational-design-patterns/builder-patterns.md) — Implements a fluent builder pattern to define container specifications before instantiating the actual resource.
