Net4x.DapperLibrary.Docker
1.9.9
dotnet add package Net4x.DapperLibrary.Docker --version 1.9.9
NuGet\Install-Package Net4x.DapperLibrary.Docker -Version 1.9.9
<PackageReference Include="Net4x.DapperLibrary.Docker" Version="1.9.9" />
<PackageVersion Include="Net4x.DapperLibrary.Docker" Version="1.9.9" />
<PackageReference Include="Net4x.DapperLibrary.Docker" />
paket add Net4x.DapperLibrary.Docker --version 1.9.9
#r "nuget: Net4x.DapperLibrary.Docker, 1.9.9"
#:package Net4x.DapperLibrary.Docker@1.9.9
#addin nuget:?package=Net4x.DapperLibrary.Docker&version=1.9.9
#tool nuget:?package=Net4x.DapperLibrary.Docker&version=1.9.9
DapperLibrary.Docker
Helpers to provision and use transient Docker database containers for integration tests and local development. The project provides installers, runtime checks and Testcontainers-based container wrappers to create disposable database instances (SQL Server, PostgreSQL, MySQL, Oracle, Firebird) and helpers to copy/restore database backups into containers.
Overview
- Purpose: make it easy to run database instances in Docker for automated tests or local runs without requiring a permanent DB server installation.
- Approach: use a small runtime layer that detects Docker, can attempt to install Docker (platform-specific guidance), and uses Testcontainers / provider-specific builders to start containers and return
IDapperContextinstances wired to the container.
Main components
DockerInstaller� convenience class that can check whether the Docker CLI is available (IsInstalled) and on some platforms attempts an automated install flow. On Windows it downloads the Docker Desktop installer and launches it (requires elevation). On Linux it runs the official install script. macOS requires manual installation.DockerRun� detects whether a local Docker daemon is reachable usingDocker.DotNet(supports Unix socket and named pipe) and exposesIsRunning()/IsRunningAsync()helpers.DockerImage� small helper that checks whether a given Docker image exists locally (usesdocker image inspect) and returns boolean result. Used to determine whether to pull an image before starting a container.SqlDockerContainers<TBuilder>(base class) � common logic for SQL-based containers using Testcontainers builders. It will pull images when not present, start/stop containers and createIDapperContextinstances using provider-specific builders.Provider-specific container classes
MsSqlDockerContainers� helpers for SQL Server containers and aGetDapperContextUsingDockerContainerthat returns aSqlDapperContexttied to the TestcontainersMsSqlContainer. Includes logic to restore a backup into the container viaMsSqlContainerExtensions.RestoreDatabaseFromBackupAsync.PostgresDockerContainers� starts a PostgreSQL container and returns aPostgresDapperContext.MySqlDockerContainers� starts a MySQL container and returns aMySqlDapperContext.OracleDockerContainers� starts an Oracle container (via Testcontainers Oracle) and returns anOracleDapperContext.FirebirdDockerContainers� Firebird support if available in the build.
Extensions and helpers
DockerContainerExtensions.CopyFileIntoContainerUsingDockerCopy� usesdocker exec/docker cpto copy a local backup file into a container path (used mainly by SQL Server restore helpers).MsSqlContainerExtensions.RestoreDatabaseFromBackupAsync� copies a backup into a SQL Server container and triggers a restore operation via the container's attachedIDapperContext.
Usage (typical test bootstrap)
Ensure Docker is available and running. The library exposes helpers but does not fully manage Docker Desktop lifecycle for you:
if (!DockerRun.Instance.IsRunning()) { // either instruct developer/CI to start Docker or call DockerInstaller.Instance.EnsureIsInstalled() }Start a container and obtain an
IDapperContextbound to it (example for SQL Server):var (ctx, container) = MsSqlDockerContainers.Instance.GetDapperContextUsingDockerContainer(); // Use ctx for integration tests, then dispose ctx.Dispose(); // will stop and dispose the containerUse restore helper if you need to load a .bak file into the container:
var container = /* started Testcontainers MsSqlContainer */; await container.RestoreDatabaseFromBackupAsync(ctx, "localpath/to/backup.bak", "TargetDbName");
Notes and recommendations
- Testcontainers dependency: the code uses
DotNet.Testcontainers(Testcontainers.MsSql, Testcontainers.PostgreSql, Testcontainers.MySql, etc.) to manage container lifecycles. Include compatible package versions for your target runtime. - Platform differences:
- Windows: Docker Desktop installer path is downloaded and launched by
DockerInstallerand may require administrator privileges. - Linux: the installer runs the official
get.docker.comscript and requiressudoto complete. - macOS: user must install Docker Desktop manually.
- Windows: Docker Desktop installer path is downloaded and launched by
- The helpers will pull container images when missing; this can take time on CI or first-run.
- Calling
GetDapperContextUsingDockerContainerreturns a context that will attempt to stop & dispose the container when the context is disposed (helps keep tests isolated). - Copying large backup files into containers uses the
dockerCLI (docker cp) under the hood. Ensure the CLI is available on PATH and the current user has permissions to interact with Docker.
Security and CI
- In CI environments prefer pre-pulled images or caching to reduce test startup time.
- Running the install flows (automatic installers) requires elevated privileges and is not suitable for most CI setups � prefer pre-configured runners with Docker already installed.
Extensibility
- Add or override Docker images by setting the
DockerImageproperty on provider container singletons before callingGetDapperContextUsingDockerContainer. - Implement custom builders by extending the base
SqlDockerContainers<TBuilder>patterns for other database engines.
License / Contributing
See repository root for license and contribution guidelines.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging (>= 10.0.0)
- MySql.Data (>= 9.4.0)
- Net4x.DapperLibrary.Base (>= 1.9.9)
- Net4x.DapperLibrary.Firebird (>= 1.9.9)
- Net4x.DapperLibrary.MySql (>= 1.9.9)
- Net4x.DapperLibrary.Postgres (>= 1.9.9)
- Net4x.DapperLibrary.SqlServer (>= 1.9.9)
- Testcontainers.FirebirdSql (>= 4.9.0)
- Testcontainers.MsSql (>= 4.9.0)
- Testcontainers.MySql (>= 4.9.0)
- Testcontainers.PostgreSql (>= 4.9.0)
-
.NETStandard 2.1
- Microsoft.Extensions.Logging (>= 10.0.0)
- MySql.Data (>= 9.4.0)
- Net4x.DapperLibrary.Base (>= 1.9.9)
- Net4x.DapperLibrary.Firebird (>= 1.9.9)
- Net4x.DapperLibrary.MySql (>= 1.9.9)
- Net4x.DapperLibrary.Oracle (>= 1.9.9)
- Net4x.DapperLibrary.Postgres (>= 1.9.9)
- Net4x.DapperLibrary.SqlServer (>= 1.9.9)
- Testcontainers.FirebirdSql (>= 4.9.0)
- Testcontainers.MsSql (>= 4.9.0)
- Testcontainers.MySql (>= 4.9.0)
- Testcontainers.Oracle (>= 4.9.0)
- Testcontainers.PostgreSql (>= 4.9.0)
-
net10.0
- Microsoft.Extensions.Logging (>= 10.0.0)
- MySql.Data (>= 9.4.0)
- Net4x.DapperLibrary.Base (>= 1.9.9)
- Net4x.DapperLibrary.Firebird (>= 1.9.9)
- Net4x.DapperLibrary.MySql (>= 1.9.9)
- Net4x.DapperLibrary.Oracle (>= 1.9.9)
- Net4x.DapperLibrary.Postgres (>= 1.9.9)
- Net4x.DapperLibrary.SqlServer (>= 1.9.9)
- Testcontainers.FirebirdSql (>= 4.9.0)
- Testcontainers.MsSql (>= 4.9.0)
- Testcontainers.MySql (>= 4.9.0)
- Testcontainers.Oracle (>= 4.9.0)
- Testcontainers.PostgreSql (>= 4.9.0)
-
net6.0
- Microsoft.Extensions.Logging (>= 10.0.0)
- MySql.Data (>= 9.4.0)
- Net4x.DapperLibrary.Base (>= 1.9.9)
- Net4x.DapperLibrary.Firebird (>= 1.9.9)
- Net4x.DapperLibrary.MySql (>= 1.9.9)
- Net4x.DapperLibrary.Oracle (>= 1.9.9)
- Net4x.DapperLibrary.Postgres (>= 1.9.9)
- Net4x.DapperLibrary.SqlServer (>= 1.9.9)
- Testcontainers.FirebirdSql (>= 4.9.0)
- Testcontainers.MsSql (>= 4.9.0)
- Testcontainers.MySql (>= 4.9.0)
- Testcontainers.Oracle (>= 4.9.0)
- Testcontainers.PostgreSql (>= 4.9.0)
-
net8.0
- Microsoft.Extensions.Logging (>= 10.0.0)
- MySql.Data (>= 9.4.0)
- Net4x.DapperLibrary.Base (>= 1.9.9)
- Net4x.DapperLibrary.Firebird (>= 1.9.9)
- Net4x.DapperLibrary.MySql (>= 1.9.9)
- Net4x.DapperLibrary.Oracle (>= 1.9.9)
- Net4x.DapperLibrary.Postgres (>= 1.9.9)
- Net4x.DapperLibrary.SqlServer (>= 1.9.9)
- Testcontainers.FirebirdSql (>= 4.9.0)
- Testcontainers.MsSql (>= 4.9.0)
- Testcontainers.MySql (>= 4.9.0)
- Testcontainers.Oracle (>= 4.9.0)
- Testcontainers.PostgreSql (>= 4.9.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Net4x.DapperLibrary.Docker:
| Package | Downloads |
|---|---|
|
Net4x.DapperLibrary.Installation
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.