{"id":17685190,"url":"https://github.com/isen-ng/testcontainers-dotnet","last_synced_at":"2025-10-14T21:35:57.481Z","repository":{"id":41394693,"uuid":"171409837","full_name":"isen-ng/testcontainers-dotnet","owner":"isen-ng","description":"dotnet port of testcontainers-java","archived":false,"fork":false,"pushed_at":"2024-05-10T03:41:55.000Z","size":793,"stargazers_count":33,"open_issues_count":3,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-05-10T04:34:44.581Z","etag":null,"topics":["csharp","dotnet","dotnet-core","nunit","test-containers","xunit"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isen-ng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"isenng","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://paypal.me/isenng"]}},"created_at":"2019-02-19T05:17:49.000Z","updated_at":"2024-06-19T01:30:09.912Z","dependencies_parsed_at":"2024-01-17T03:51:34.484Z","dependency_job_id":"afa58fe2-04d1-41fc-8d95-196579ebc5d9","html_url":"https://github.com/isen-ng/testcontainers-dotnet","commit_stats":{"total_commits":202,"total_committers":5,"mean_commits":40.4,"dds":"0.20297029702970293","last_synced_commit":"a0f16980d572b3d9c7b5d8aaad41c2742c7014cb"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isen-ng%2Ftestcontainers-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isen-ng%2Ftestcontainers-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isen-ng%2Ftestcontainers-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isen-ng%2Ftestcontainers-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isen-ng","download_url":"https://codeload.github.com/isen-ng/testcontainers-dotnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799984,"owners_count":21163404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","dotnet-core","nunit","test-containers","xunit"],"created_at":"2024-10-24T10:26:51.076Z","updated_at":"2025-10-14T21:35:52.454Z","avatar_url":"https://github.com/isen-ng.png","language":"C#","funding_links":["https://patreon.com/isenng","https://paypal.me/isenng"],"categories":[],"sub_categories":[],"readme":"# This repo is no longer supported or updated!\n\nPlease use the official repo: https://github.com/testcontainers/testcontainers-dotnet\n\n# TestContainers dotnet\n\n[![codecov](https://codecov.io/gh/isen-ng/testcontainers-dotnet/branch/master/graph/badge.svg)](https://codecov.io/gh/isen-ng/testcontainers-dotnet)\n[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=testcontainers-dotnet\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=testcontainers-dotnet)\n[![Donation](https://img.shields.io/badge/Buy-me%20a%20coffee-orange.svg)](https://paypal.me/isenng)\n\n\u003e Testcontainers is a dotnet standard 2.0 library that supports NUnit and XUnit tests, providing lightweight, throwaway\ninstances of common databases or anything else that can run in a Docker container.\n\u003e\n\u003e Uses common Microsoft dependency injection patterns, app and host settings, and Microsoft Extensions Logging (MEL).\n\u003e\n\u003e This is a port of [testcontainers-java](https://github.com/testcontainers/testcontainers-java) for dotnet.\n\n### Build statuses\n\n[![Linux build status](https://img.shields.io/travis/com/isen-ng/testcontainers-dotnet/master?label=linux)](https://travis-ci.org/isen-ng/testcontainers-dotnet)\n\u003c!--[![LCOW build status](https://img.shields.io/appveyor/ci/isen-ng/testcontainers-dotnet/master?label=experimental-lcow)](https://ci.appveyor.com/project/isen-ng/testcontainers-dotnet/branch/master)--\u003e\n\n---\n\n## Feature parity\n\n## Linux environment\n\n* Container management\n* Docker providers\n  - Unix socket\n  - Environment\n* Image management\n  - Pulling from public repo\n  - Building from docker file\n* Network management\n  - User defined networks\n  - Network aliases\n* Ryuk resource reaper\n\n## Linux containers on Windows (LCOW) environment\n\n* Container management\n* Docker providers\n  - Npipe\n  - Environment\n* Image management\n  - Pulling from public repo\n  - Building from docker file\n* Network management\n  - User defined networks\n  - Network aliases\n* Ryuk resource reaper\n* [Need help] Classic LCOW CI on Win10 (GUI) environment\n  - Requires the GUI version of Docker Desktop for Windows\n\n## Experimental LCOW on Windows environment\n\n* Not supported\n  - Primarily because this experimental feature does not allow mounting of the docker socket/npipe into a container\n  - [More info](https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/linux-containers)\n\n## Built-in containers\n\n| Container            | Readme                                                | Version\n|----------------------|-------------------------------------------------------|--------\n| Generic Container    | --                                                    | [![Generic](https://img.shields.io/nuget/v/TestContainers.Container.Abstractions.svg)](https://www.nuget.org/packages/TestContainers.Container.Abstractions/)\n| MsSql Container      | [README](src/Container.Database.MsSql/README.md)      | [![MySql](https://img.shields.io/nuget/v/TestContainers.Container.Database.MsSql.svg)](https://www.nuget.org/packages/TestContainers.Container.Database.MsSql/)\n| PostgreSql Container | [README](src/Container.Database.PostgreSql/README.md) | [![PostgreSql](https://img.shields.io/nuget/v/TestContainers.Container.Database.PostgreSql.svg)](https://www.nuget.org/packages/TestContainers.Container.Database.PostgreSql/)\n| ArangoDb Container   | [README](src/Container.Database.ArangoDb/README.md)   | [![ArangoDb](https://img.shields.io/nuget/v/TestContainers.Container.Database.ArangoDb.svg)](https://www.nuget.org/packages/TestContainers.Container.Database.ArangoDb/)\n| Mysql Container      | [README](src/Container.Database.MySql/README.md)      | [![MySql](https://img.shields.io/nuget/v/TestContainers.Container.Database.MySql.svg)](https://www.nuget.org/packages/TestContainers.Container.Database.MySql/)\n\n\n## Example code\n\nFor more examples, see [integration tests](test/Container.Abstractions.Integration.Tests/Fixtures/GenericContainerFixture.cs)\n\n### Start a container by pulling the image from a remote repository\n\n```csharp\nvar container = new ContainerBuilder\u003cGenericContainer\u003e()\n    .ConfigureHostConfiguration(builder =\u003e builder.AddInMemoryCollection()) // host settings\n    .ConfigureAppConfiguration((context, builder) =\u003e builder.AddInMemoryCollection()) // app settings\n    .ConfigureDockerImageName(PlatformSpecific.TinyDockerImage)\n    .ConfigureLogging(builder =\u003e builder.AddConsole()) // Microsoft extensions logging\n    .ConfigureContainer((context, container) =\u003e\n    {\n        // add labels\n        container.Labels.Add(CustomLabel.Key, CustomLabel.Value);\n\n        // add environment labels\n        container.Env[InjectedEnvVar.Key] = InjectedEnvVar.Value;\n\n        // add exposed ports (automatically mapped to higher port\n        container.ExposedPorts.Add(ExposedPort);\n\n        /*\n         to do something like `docker run -p 2345:34567 alpine:latest`,\n         both expose port and port binding must be set\n         */\n        container.ExposedPorts.Add(PortBinding.Key);\n        container.PortBindings.Add(PortBinding.Key, PortBinding.Value);\n\n        // add bind mounts\n        container.BindMounts.Add(new Bind\n        {\n            HostPath = HostPathBinding.Key,\n            ContainerPath = HostPathBinding.Value,\n            AccessMode = AccessMode.ReadOnly\n        });\n\n        // set working directory\n        container.WorkingDirectory = WorkingDirectory;\n\n        // set command to run\n        container.Command = PlatformSpecific.ShellCommand(\n                $\"{PlatformSpecific.Touch} {FileTouchedByCommand}; {PlatformSpecific.Shell}\")\n            .ToList();\n    })\n    .Build();\n```\n\n### Start a container by building the image from a Dockerfile\n\n```csharp\nvar image = new ImageBuilder\u003cDockerfileImage\u003e()\n    .ConfigureHostConfiguration(builder =\u003e builder.AddInMemoryCollection()) // host settings\n    .ConfigureAppConfiguration((context, builder) =\u003e builder.AddInMemoryCollection()) // app settings\n    .ConfigureLogging(builder =\u003e builder.AddConsole()) // Microsoft extensions logging\n    .ConfigureImage((context, image) =\u003e\n    {\n        image.DockerfilePath = \"Dockerfile\";\n        image.DeleteOnExit = false;\n\n        // add the Dockerfile into the build context\n        image.Transferables.Add(\"Dockerfile\", new MountableFile(PlatformSpecific.DockerfileImagePath));\n        // add other files required by the Dockerfile into the build context\n        image.Transferables.Add(\".\", new MountableFile(PlatformSpecific.DockerfileImageContext));\n    })\n    .Build();\n\nvar container = new ContainerBuilder\u003cGenericContainer\u003e()\n    .ConfigureDockerImage(image)\n    .ConfigureHostConfiguration(builder =\u003e builder.AddInMemoryCollection()) // host settings\n    .ConfigureAppConfiguration((context, builder) =\u003e builder.AddInMemoryCollection()) // app settings\n    .ConfigureLogging(builder =\u003e builder.AddConsole()) // Microsoft extensions logging\n    .ConfigureContainer((h, c) =\u003e\n    {\n        c.ExposedPorts.Add(80);\n    })\n    .Build();\n```\n\nor\n\n```csharp\nvar container = new ContainerBuilder\u003cGenericContainer\u003e()\n    .ConfigureDockerImage((hostContext, builderContext) =\u003e\n    {\n        return new ImageBuilder\u003cDockerfileImage\u003e()\n            // share the app/host config and service collection from the parent builder context\n            .WithContextFrom(builderContext)\n            .ConfigureImage((context, image) =\u003e\n            {\n                image.DeleteOnExit = false;\n                image.BasePath = PlatformSpecific.DockerfileImageContext;\n\n                // add the Dockerfile as like the command line `-f \u003cpath to dockerfile`\n                image.DockerfilePath = \"Dockerfile\";\n                image.Transferables.Add(\"Dockerfile\", new MountableFile(PlatformSpecific.DockerfileImagePath));\n\n                // add other files required by the Dockerfile into the build context\n                image.Transferables.Add(\"folder1\", new MountableFile(DockerfileImageTransferableFolder));\n            })\n            .Build();\n    })\n    .ConfigureHostConfiguration(builder =\u003e builder.AddInMemoryCollection()) // host settings\n    .ConfigureAppConfiguration((context, builder) =\u003e builder.AddInMemoryCollection()) // app settings\n    .ConfigureLogging(builder =\u003e builder.AddConsole()) // Microsoft extensions logging\n    .ConfigureContainer((h, c) =\u003e\n    {\n        c.ExposedPorts.Add(80);\n    })\n    .Build();\n```\n\n### Start a container with a new network\n\n```csharp\nvar container = new ContainerBuilder\u003cGenericContainer\u003e()\n    .ConfigureNetwork((hostContext, builderContext) =\u003e\n    {\n        return new NetworkBuilder\u003cUserDefinedNetwork\u003e()\n            // share the app/host config and service collection from the parent builder context\n            .WithContextFrom(builderContext)\n            .ConfigureNetwork((context, network) =\u003e\n            {\n                // be careful when setting static network names\n                // if they already exists, the existing network will be used\n                // otherwise, the default NetworkName is a random string\n                network.NetworkName = \"my_network\"\n            })\n            .Build();\n    })\n    .ConfigureHostConfiguration(builder =\u003e builder.AddInMemoryCollection()) // host settings\n    .ConfigureAppConfiguration((context, builder) =\u003e builder.AddInMemoryCollection()) // app settings\n    .ConfigureLogging(builder =\u003e builder.AddConsole()) // Microsoft extensions logging\n    .ConfigureContainer((h, c) =\u003e\n    {\n        c.ExposedPorts.Add(80);\n    })\n    .Build();\n```\n\n## Configuring TestContainers-dotnet\n\nThere are some configurations to testcontainers-dotnet that cannot be performed in code or injected.\nThese configuration can be set in environment variables before the first instance of your container is built.\n\n | Variable          | Default                             | Description\n |-------------------|-------------------------------------|------------\n | `REAPER_DISABLED` | (not-set)                           | When set to `1` or `true`, disables starting of the reaper container\n | `REAPER_IMAGE`    | `quay.io/testcontainers/ryuk:0.2.3` | Change which container image to use for reaper\n | `REAPER_PORT`     | (not-set)                           | Use the given port for reaper instead of a dynamic port\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisen-ng%2Ftestcontainers-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisen-ng%2Ftestcontainers-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisen-ng%2Ftestcontainers-dotnet/lists"}