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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Net4x.DapperLibrary.Docker" Version="1.9.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Net4x.DapperLibrary.Docker" Version="1.9.9" />
                    
Directory.Packages.props
<PackageReference Include="Net4x.DapperLibrary.Docker" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Net4x.DapperLibrary.Docker --version 1.9.9
                    
#r "nuget: Net4x.DapperLibrary.Docker, 1.9.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Net4x.DapperLibrary.Docker@1.9.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Net4x.DapperLibrary.Docker&version=1.9.9
                    
Install as a Cake Addin
#tool nuget:?package=Net4x.DapperLibrary.Docker&version=1.9.9
                    
Install as a Cake Tool

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 IDapperContext instances 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 using Docker.DotNet (supports Unix socket and named pipe) and exposes IsRunning() / IsRunningAsync() helpers.

  • DockerImage � small helper that checks whether a given Docker image exists locally (uses docker 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 create IDapperContext instances using provider-specific builders.

  • Provider-specific container classes

    • MsSqlDockerContainers � helpers for SQL Server containers and a GetDapperContextUsingDockerContainer that returns a SqlDapperContext tied to the Testcontainers MsSqlContainer. Includes logic to restore a backup into the container via MsSqlContainerExtensions.RestoreDatabaseFromBackupAsync.
    • PostgresDockerContainers � starts a PostgreSQL container and returns a PostgresDapperContext.
    • MySqlDockerContainers � starts a MySQL container and returns a MySqlDapperContext.
    • OracleDockerContainers � starts an Oracle container (via Testcontainers Oracle) and returns an OracleDapperContext.
    • FirebirdDockerContainers � Firebird support if available in the build.
  • Extensions and helpers

    • DockerContainerExtensions.CopyFileIntoContainerUsingDockerCopy � uses docker exec/docker cp to 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 attached IDapperContext.

Usage (typical test bootstrap)

  1. 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()
    }
    
  2. Start a container and obtain an IDapperContext bound 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 container
    
  3. Use 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 DockerInstaller and may require administrator privileges.
    • Linux: the installer runs the official get.docker.com script and requires sudo to complete.
    • macOS: user must install Docker Desktop manually.
  • The helpers will pull container images when missing; this can take time on CI or first-run.
  • Calling GetDapperContextUsingDockerContainer returns 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 docker CLI (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 DockerImage property on provider container singletons before calling GetDapperContextUsingDockerContainer.
  • 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
1.9.9 0 12/22/2025
1.6.0.12 197 12/12/2025
1.6.0.11 170 12/12/2025
1.6.0.10 498 12/9/2025