CINXE.COM

Testcontainers for .NET

<!doctype html> <html lang="en" class="no-js"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <link rel="canonical" href="https://dotnet.testcontainers.org/"> <link rel="icon" href="favicon.ico"> <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-8.5.10"> <title>Testcontainers for .NET</title> <link rel="stylesheet" href="assets/stylesheets/main.975780f9.min.css"> <link rel="stylesheet" href="assets/stylesheets/palette.2505c338.min.css"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback"> <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style> <link rel="stylesheet" href="css/extra.css"> <link rel="stylesheet" href="css/tc-header.css"> <script>__md_scope=new URL(".",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script> <!-- Cloudflare Web Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "e44a95720257486eab94698a6b4c6ca6"}'></script><!-- End Cloudflare Web Analytics --> <link href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600&display=swap" rel="stylesheet"> <script rel="text/javascript" src="/js/tc-header.js" defer></script> </head> <body dir="ltr" data-md-color-scheme="testcontainers" data-md-color-primary="" data-md-color-accent=""> <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off"> <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off"> <label class="md-overlay" for="__drawer"></label> <div data-md-component="skip"> <a href="#welcome-to-testcontainers-for-net" class="md-skip"> Skip to content </a> </div> <div data-md-component="announce"> </div> <!-- Copyright (c) 2016-2023 Martin Donath <martin.donath@squidfunk.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> <!-- Determine base classes --> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display: none"> <symbol id="icon-external" viewBox="0 0 15 17" width="15" height="17" fill="currentColor"> <path d="M9.334 1.254a.999.999 0 1 0 0 2h1.584l-5.29 5.293a1.002 1.002 0 0 0 1.415 1.416l5.29-5.294v1.585a.999.999 0 1 0 2 0v-4c0-.553-.446-1-1-1h-4Zm-6.5 1a2.5 2.5 0 0 0-2.5 2.5v8a2.5 2.5 0 0 0 2.5 2.5h8a2.5 2.5 0 0 0 2.5-2.5v-2.5a.999.999 0 1 0-2 0v2.5c0 .275-.226.5-.5.5h-8a.501.501 0 0 1-.5-.5v-8c0-.275.224-.5.5-.5h2.5a.999.999 0 1 0 0-2h-2.5Z" /> </symbol> <symbol id="icon-caret" width="10" height="10" viewBox="0 0 10 10" fill="currentColor"> <path d="M.487 2.157a1.662 1.662 0 0 1 2.357 0L5 4.313l2.156-2.156a1.657 1.657 0 0 1 2.354 0 1.657 1.657 0 0 1 0 2.354L6.177 7.847a1.66 1.66 0 0 1-1.815.36 1.658 1.658 0 0 1-.54-.361L.487 4.51a1.66 1.66 0 0 1 .001-2.353Z" /> </symbol> <symbol id="icon-slack" class="icon-slack" width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="currentColor"> <path d="M8.76.06a2.392 2.392 0 0 0-2.207 3.309A2.392 2.392 0 0 0 8.76 4.847h2.39V2.453A2.392 2.392 0 0 0 8.76.06Zm0 6.384H2.39A2.392 2.392 0 0 0 .18 9.753a2.392 2.392 0 0 0 2.208 1.479h6.372a2.391 2.391 0 0 0 2.208-3.31 2.39 2.39 0 0 0-2.208-1.478ZM23.893 8.837a2.392 2.392 0 0 0-3.304-2.21 2.392 2.392 0 0 0-1.474 2.21v2.395h2.39a2.391 2.391 0 0 0 2.388-2.395Zm-6.371 0V2.453a2.39 2.39 0 1 0-4.779 0v6.384a2.39 2.39 0 1 0 4.779 0ZM15.133 24a2.391 2.391 0 0 0 2.389-2.394 2.39 2.39 0 0 0-2.39-2.394h-2.389v2.394A2.39 2.39 0 0 0 15.133 24Zm0-6.384h6.371a2.39 2.39 0 0 0 2.39-2.394 2.392 2.392 0 0 0-2.39-2.394h-6.372a2.391 2.391 0 0 0-2.389 2.394 2.39 2.39 0 0 0 2.39 2.394ZM0 15.222a2.391 2.391 0 0 0 4.08 1.691 2.391 2.391 0 0 0 .699-1.691v-2.394h-2.39A2.392 2.392 0 0 0 0 15.222m6.372 0v6.384a2.391 2.391 0 0 0 3.304 2.211 2.39 2.39 0 0 0 1.474-2.211v-6.384a2.392 2.392 0 0 0-2.39-2.394 2.391 2.391 0 0 0-2.388 2.394" /> </symbol> <symbol id="icon-github" class="icon-github" width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="currentColor"> <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57C20.565 21.795 24 17.295 24 12c0-6.63-5.37-12-12-12Z" /> </symbol> </svg> <header id="site-header"> <div class="brand"> <a href="https://testcontainers.com/" class="logo"> <img src="/testcontainers-logo.svg" alt="Testcontainers" width="183" height="48"/> </a> <button id="mobile-menu-toggle"> Menu <svg width="30" height="30" viewBox="0 0 30 30" fill="currentColor" xmlns="http://www.w3.org/2000/svg"> <rect y="22" width="30" height="4" rx="2"/> <rect y="13" width="30" height="4" rx="2"/> <rect y="4" width="30" height="4" rx="2"/> </svg> </button> </div> <nav> <ul class="menu"> <li class="menu-item"> <a href="https://testcontainers.com/desktop/"> Desktop </a> </li> <li class="menu-item"> <a href="https://testcontainers.com/cloud/"> Cloud </a> </li> <li class="menu-item"> <a href="https://testcontainers.com/getting-started/"> Getting Started </a> </li> <li class="menu-item"> <a href="https://testcontainers.com/guides/"> Guides </a> </li> <li class="menu-item"> <a href="https://testcontainers.com/modules/"> Modules </a> </li> <li class="menu-item has-children"> <button> Docs <svg class="icon-caret" width="10" height="10" viewBox="0 0 10 10"> <use href="#icon-caret"></use> </svg> </button> <ul class="menu-dropdown"> <li class="menu-dropdown-item"> <a href="https://java.testcontainers.org/" > <img src="/language-logos/java.svg" alt="" width="24" height="24"/> Testcontainers for Java </a> </li> <li class="menu-dropdown-item"> <a href="https://golang.testcontainers.org/" > <img src="/language-logos/go.svg" alt="" width="24" height="24"/> Testcontainers for Go </a> </li> <li class="menu-dropdown-item"> <a href="https://dotnet.testcontainers.org/" > <img src="/language-logos/dotnet.svg" alt="" width="24" height="24"/> Testcontainers for .NET </a> </li> <li class="menu-dropdown-item"> <a href="https://node.testcontainers.org/" > <img src="/language-logos/nodejs.svg" alt="" width="24" height="24"/> Testcontainers for Node.js </a> </li> <li class="menu-dropdown-item"> <a href="https://testcontainers-python.readthedocs.io/en/latest/" target="_blank"> <img src="/language-logos/python.svg" alt="" width="24" height="24"/> Testcontainers for Python <svg class="icon-external" width="15" height="17" viewBox="0 0 15 17" aria-hidden="true" focusable="false"> <use href="#icon-external"></use> </svg> </a> </li> <li class="menu-dropdown-item"> <a href="https://docs.rs/testcontainers/latest/testcontainers/" target="_blank"> <img src="/language-logos/rust.svg" alt="" width="24" height="24"/> Testcontainers for Rust <svg class="icon-external" width="15" height="17" viewBox="0 0 15 17" aria-hidden="true" focusable="false"> <use href="#icon-external"></use> </svg> </a> </li> <li class="menu-dropdown-item"> <a href="https://github.com/testcontainers/testcontainers-hs" target="_blank"> <img src="/language-logos/haskell.svg" alt="" width="24" height="24"/> Testcontainers for Haskell <svg class="icon-external" width="15" height="17" viewBox="0 0 15 17" aria-hidden="true" focusable="false"> <use href="#icon-external"></use> </svg> </a> </li> <li class="menu-dropdown-item"> <a href="https://github.com/testcontainers/testcontainers-ruby" target="_blank"> <img src="/language-logos/ruby.svg" alt="" width="24" height="24"/> Testcontainers for Ruby <svg class="icon-external" width="15" height="17" viewBox="0 0 15 17" aria-hidden="true" focusable="false"> <use href="#icon-external"></use> </svg> </a> </li> </ul> </li> <li class="menu-item"> <a href="https://slack.testcontainers.org/"> <svg class="icon-slack" width="24" height="24" viewBox="0 0 24 24"> <use href="#icon-slack"></use> </svg> Slack </a> </li> <li class="menu-item"> <a href="https://github.com/testcontainers"> <svg class="icon-github" width="24" height="24" viewBox="0 0 24 24"> <use href="#icon-github"></use> </svg> GitHub </a> </li> </ul> </nav> </header> <!-- Header --> <header class="md-header md-header--shadow" data-md-component="header"> <nav class="md-header__inner md-grid" aria-label="" > <!-- Button to open drawer --> <label class="md-header__button md-icon" for="__drawer"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg> </label> <!-- Header title --> <div class="md-header__title" data-md-component="header-title"> <div class="md-header__ellipsis"> <div class="md-header__topic"> <a href="."> <span class="md-ellipsis"> Testcontainers for .NET </span> </a> </div> </div> </div> <!-- Color palette --> <!-- Site language selector --> <!-- Button to open search modal --> <label class="md-header__button md-icon" for="__search"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg> </label> <!-- Search interface --> <div class="md-search" data-md-component="search" role="dialog"> <label class="md-search__overlay" for="__search"></label> <div class="md-search__inner" role="search"> <form class="md-search__form" name="search"> <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required> <label class="md-search__icon md-icon" for="__search"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg> </label> <nav class="md-search__options" aria-label="Search"> <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg> </button> </nav> </form> <div class="md-search__output"> <div class="md-search__scrollwrap" data-md-scrollfix> <div class="md-search-result" data-md-component="search-result"> <div class="md-search-result__meta"> Initializing search </div> <ol class="md-search-result__list"></ol> </div> </div> </div> </div> </div> <!-- Repository information --> <div class="md-header__source"> <a href="https://github.com/testcontainers/testcontainers-dotnet" title="Go to repository" class="md-source" data-md-component="source"> <div class="md-source__icon md-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg> </div> <div class="md-source__repository"> testcontainers-dotnet </div> </a> </div> </nav> <!-- Navigation tabs (sticky) --> </header> <div class="md-container" data-md-component="container"> <main class="md-main" data-md-component="main"> <div class="md-main__inner md-grid"> <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" > <div class="md-sidebar__scrollwrap"> <div class="md-sidebar__inner"> <!-- Copyright (c) 2016-2023 Martin Donath <martin.donath@squidfunk.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> <!-- Determine class according to configuration --> <!-- Main navigation --> <nav class="md-nav md-nav--primary" aria-label="" data-md-level="0"> <!-- Site title --> <label class="md-nav__title" for="__drawer"> Content </label> <!-- Repository information --> <div class="md-nav__source"> <a href="https://github.com/testcontainers/testcontainers-dotnet" title="Go to repository" class="md-source" data-md-component="source"> <div class="md-source__icon md-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg> </div> <div class="md-source__repository"> testcontainers-dotnet </div> </a> </div> <!-- Render item list --> <ul class="md-nav__list" data-md-scrollfix> <li class="md-nav__item md-nav__item--active"> <input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc"> <label class="md-nav__link md-nav__link--active" for="__toc"> Welcome to Testcontainers for .NET! <span class="md-nav__icon md-icon"></span> </label> <a href="." class="md-nav__link md-nav__link--active"> Welcome to Testcontainers for .NET! </a> <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> <label class="md-nav__title" for="__toc"> <span class="md-nav__icon md-icon"></span> Table of contents </label> <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix> <li class="md-nav__item"> <a href="#about" class="md-nav__link"> About </a> </li> <li class="md-nav__item"> <a href="#supported-operating-systems" class="md-nav__link"> Supported operating systems </a> </li> <li class="md-nav__item"> <a href="#system-requirements" class="md-nav__link"> System requirements </a> </li> <li class="md-nav__item"> <a href="#license" class="md-nav__link"> License </a> </li> <li class="md-nav__item"> <a href="#copyright" class="md-nav__link"> Copyright </a> </li> </ul> </nav> </li> <li class="md-nav__item"> <a href="cicd/" class="md-nav__link"> Continuous Integration </a> </li> <li class="md-nav__item"> <a href="custom_configuration/" class="md-nav__link"> Custom Configuration </a> </li> <li class="md-nav__item"> <a href="api/create_docker_image/" class="md-nav__link"> Creating an image </a> </li> <li class="md-nav__item"> <a href="api/create_docker_container/" class="md-nav__link"> Creating a container </a> </li> <li class="md-nav__item"> <a href="api/create_docker_network/" class="md-nav__link"> Network communication </a> </li> <li class="md-nav__item"> <a href="api/low_level_api_access/" class="md-nav__link"> Low level API access </a> </li> <li class="md-nav__item"> <a href="api/resource_reaper/" class="md-nav__link"> Resource Reaper </a> </li> <li class="md-nav__item"> <a href="api/resource_reuse/" class="md-nav__link"> Resource Reuse </a> </li> <li class="md-nav__item"> <a href="api/wait_strategies/" class="md-nav__link"> Wait Strategies </a> </li> <li class="md-nav__item"> <a href="api/best_practices/" class="md-nav__link"> Best Practices </a> </li> <li class="md-nav__item"> <a href="dind/" class="md-nav__link"> Running inside a container </a> </li> <li class="md-nav__item"> <a href="full_framework/" class="md-nav__link"> .NET Framework </a> </li> <li class="md-nav__item"> <a href="test_frameworks/xunit_net/" class="md-nav__link"> Testing with xUnit.net </a> </li> <li class="md-nav__item md-nav__item--nested"> <input class="md-nav__toggle md-toggle" data-md-toggle="__nav_15" type="checkbox" id="__nav_15" > <label class="md-nav__link" for="__nav_15"> Examples <span class="md-nav__icon md-icon"></span> </label> <nav class="md-nav" aria-label="Examples" data-md-level="1"> <label class="md-nav__title" for="__nav_15"> <span class="md-nav__icon md-icon"></span> Examples </label> <ul class="md-nav__list" data-md-scrollfix> <li class="md-nav__item"> <a href="examples/aspnet/" class="md-nav__link"> ASP.NET Core </a> </li> </ul> </nav> </li> <li class="md-nav__item md-nav__item--nested"> <input class="md-nav__toggle md-toggle" data-md-toggle="__nav_16" type="checkbox" id="__nav_16" > <label class="md-nav__link" for="__nav_16"> Modules <span class="md-nav__icon md-icon"></span> </label> <nav class="md-nav" aria-label="Modules" data-md-level="1"> <label class="md-nav__title" for="__nav_16"> <span class="md-nav__icon md-icon"></span> Modules </label> <ul class="md-nav__list" data-md-scrollfix> <li class="md-nav__item"> <a href="modules/" class="md-nav__link"> Modules </a> </li> <li class="md-nav__item"> <a href="modules/activemq/" class="md-nav__link"> Apache ActiveMQ Artemis </a> </li> <li class="md-nav__item"> <a href="modules/cassandra/" class="md-nav__link"> Apache Cassandra </a> </li> <li class="md-nav__item"> <a href="modules/pulsar/" class="md-nav__link"> Apache Pulsar </a> </li> <li class="md-nav__item"> <a href="modules/eventhubs/" class="md-nav__link"> Azure Event Hubs </a> </li> <li class="md-nav__item"> <a href="modules/servicebus/" class="md-nav__link"> Azure Service Bus </a> </li> <li class="md-nav__item"> <a href="modules/db2/" class="md-nav__link"> Db2 </a> </li> <li class="md-nav__item"> <a href="modules/elasticsearch/" class="md-nav__link"> Elasticsearch </a> </li> <li class="md-nav__item"> <a href="modules/mongodb/" class="md-nav__link"> MongoDB </a> </li> <li class="md-nav__item"> <a href="modules/mssql/" class="md-nav__link"> Microsoft SQL Server </a> </li> <li class="md-nav__item"> <a href="modules/neo4j/" class="md-nav__link"> Neo4j </a> </li> <li class="md-nav__item"> <a href="modules/postgres/" class="md-nav__link"> PostgreSQL </a> </li> <li class="md-nav__item"> <a href="modules/qdrant/" class="md-nav__link"> Qdrant </a> </li> <li class="md-nav__item"> <a href="modules/rabbitmq/" class="md-nav__link"> RabbitMQ </a> </li> </ul> </nav> </li> <li class="md-nav__item"> <a href="contributing/" class="md-nav__link"> Contributing </a> </li> <li class="md-nav__item"> <a href="contributing_docs/" class="md-nav__link"> Contributing to documentation </a> </li> <li class="community-callout-wrapper"> <div class="community-callout"> <h2>Join the community</h2> <ul> <li> <a href="https://slack.testcontainers.org/" target="_blank"> <img src="/community-logos/slack.svg" alt="Slack" width="30" height="31"> </a> </li> <li> <a href="https://github.com/testcontainers" target="_blank"> <img src="/community-logos/github.svg" alt="GitHub" width="30" height="31"> </a> </li> <li> <a href="https://stackoverflow.com/questions/tagged/testcontainers" target="_blank"> <img src="/community-logos/stackoverflow.svg" alt="StackOverflow" width="26" height="31"> </a> </li> <li> <a href="https://twitter.com/testcontainers" target="_blank"> <img src="/community-logos/twitter.svg" alt="Twitter" width="37" height="31"> </a> </li> </ul> </div> </li> </ul> </nav> </div> </div> </div> <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" > <div class="md-sidebar__scrollwrap"> <div class="md-sidebar__inner"> <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> <label class="md-nav__title" for="__toc"> <span class="md-nav__icon md-icon"></span> Table of contents </label> <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix> <li class="md-nav__item"> <a href="#about" class="md-nav__link"> About </a> </li> <li class="md-nav__item"> <a href="#supported-operating-systems" class="md-nav__link"> Supported operating systems </a> </li> <li class="md-nav__item"> <a href="#system-requirements" class="md-nav__link"> System requirements </a> </li> <li class="md-nav__item"> <a href="#license" class="md-nav__link"> License </a> </li> <li class="md-nav__item"> <a href="#copyright" class="md-nav__link"> Copyright </a> </li> </ul> </nav> </div> </div> </div> <div class="md-content" data-md-component="content"> <article class="md-content__inner md-typeset"> <a href="https://github.com/testcontainers/testcontainers-dotnet/edit/develop/docs/index.md" title="Edit this page" class="md-content__button md-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25Z"/></svg> </a> <h1 id="welcome-to-testcontainers-for-net">Welcome to Testcontainers for .NET!</h1> <div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Install the NuGet dependency</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><code>dotnet<span class="w"> </span>add<span class="w"> </span>package<span class="w"> </span>Testcontainers </code></pre></div></td></tr></table></div> <div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Run the Hello World container</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"> 1</span> <span class="normal"> 2</span> <span class="normal"> 3</span> <span class="normal"> 4</span> <span class="normal"> 5</span> <span class="normal"> 6</span> <span class="normal"> 7</span> <span class="normal"> 8</span> <span class="normal"> 9</span> <span class="normal">10</span> <span class="normal">11</span> <span class="normal">12</span> <span class="normal">13</span> <span class="normal">14</span> <span class="normal">15</span> <span class="normal">16</span> <span class="normal">17</span> <span class="normal">18</span> <span class="normal">19</span> <span class="normal">20</span> <span class="normal">21</span> <span class="normal">22</span> <span class="normal">23</span> <span class="normal">24</span> <span class="normal">25</span> <span class="normal">26</span> <span class="normal">27</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="c1">// Create a new instance of a container.</span> <span class="kt">var</span><span class="w"> </span><span class="n">container</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">ContainerBuilder</span><span class="p">()</span> <span class="w"> </span><span class="c1">// Set the image for the container to &quot;testcontainers/helloworld:1.2.0&quot;.</span> <span class="w"> </span><span class="p">.</span><span class="n">WithImage</span><span class="p">(</span><span class="s">&quot;testcontainers/helloworld:1.2.0&quot;</span><span class="p">)</span> <span class="w"> </span><span class="c1">// Bind port 8080 of the container to a random port on the host.</span> <span class="w"> </span><span class="p">.</span><span class="n">WithPortBinding</span><span class="p">(</span><span class="mi">8080</span><span class="p">,</span><span class="w"> </span><span class="k">true</span><span class="p">)</span> <span class="w"> </span><span class="c1">// Wait until the HTTP endpoint of the container is available.</span> <span class="w"> </span><span class="p">.</span><span class="n">WithWaitStrategy</span><span class="p">(</span><span class="n">Wait</span><span class="p">.</span><span class="n">ForUnixContainer</span><span class="p">().</span><span class="n">UntilHttpRequestIsSucceeded</span><span class="p">(</span><span class="n">r</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">r</span><span class="p">.</span><span class="n">ForPort</span><span class="p">(</span><span class="mi">8080</span><span class="p">)))</span> <span class="w"> </span><span class="c1">// Build the container configuration.</span> <span class="w"> </span><span class="p">.</span><span class="n">Build</span><span class="p">();</span> <span class="c1">// Start the container.</span> <span class="k">await</span><span class="w"> </span><span class="n">container</span><span class="p">.</span><span class="n">StartAsync</span><span class="p">()</span> <span class="w"> </span><span class="p">.</span><span class="n">ConfigureAwait</span><span class="p">(</span><span class="k">false</span><span class="p">);</span> <span class="c1">// Create a new instance of HttpClient to send HTTP requests.</span> <span class="k">using</span><span class="w"> </span><span class="nn">var</span><span class="w"> </span><span class="n">httpClient</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">HttpClient</span><span class="p">();</span> <span class="c1">// Construct the request URI by specifying the scheme, hostname, assigned random host port, and the endpoint &quot;uuid&quot;.</span> <span class="kt">var</span><span class="w"> </span><span class="n">requestUri</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">UriBuilder</span><span class="p">(</span><span class="n">Uri</span><span class="p">.</span><span class="n">UriSchemeHttp</span><span class="p">,</span><span class="w"> </span><span class="n">container</span><span class="p">.</span><span class="n">Hostname</span><span class="p">,</span><span class="w"> </span><span class="n">container</span><span class="p">.</span><span class="n">GetMappedPublicPort</span><span class="p">(</span><span class="mi">8080</span><span class="p">),</span><span class="w"> </span><span class="s">&quot;uuid&quot;</span><span class="p">).</span><span class="n">Uri</span><span class="p">;</span> <span class="c1">// Send an HTTP GET request to the specified URI and retrieve the response as a string.</span> <span class="kt">var</span><span class="w"> </span><span class="n">guid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">await</span><span class="w"> </span><span class="n">httpClient</span><span class="p">.</span><span class="n">GetStringAsync</span><span class="p">(</span><span class="n">requestUri</span><span class="p">)</span> <span class="w"> </span><span class="p">.</span><span class="n">ConfigureAwait</span><span class="p">(</span><span class="k">false</span><span class="p">);</span> <span class="c1">// Ensure that the retrieved UUID is a valid GUID.</span> <span class="n">Debug</span><span class="p">.</span><span class="n">Assert</span><span class="p">(</span><span class="n">Guid</span><span class="p">.</span><span class="n">TryParse</span><span class="p">(</span><span class="n">guid</span><span class="p">,</span><span class="w"> </span><span class="k">out</span><span class="w"> </span><span class="n">_</span><span class="p">));</span> </code></pre></div></td></tr></table></div> <p style="text-align:center"> <strong>Not using .NET? Here are other supported languages!</strong> </p> <div class="card-grid"> <a class="card-grid-item" href="https://java.testcontainers.org"> <img src="language-logos/java.svg" />Java </a> <a class="card-grid-item" href="https://golang.testcontainers.org"> <img src="language-logos/go.svg" />Go </a> <a class="card-grid-item"> <img src="language-logos/dotnet.svg" />.NET </a> <a class="card-grid-item" href="https://node.testcontainers.org"> <img src="language-logos/nodejs.svg" />Node.js </a> <a class="card-grid-item" href="https://testcontainers-python.readthedocs.io/en/latest/"> <img src="language-logos/python.svg" />Python </a> <a class="card-grid-item" href="https://docs.rs/testcontainers/latest/testcontainers/"> <img src="language-logos/rust.svg" />Rust </a> <a class="card-grid-item" href="https://github.com/testcontainers/testcontainers-hs/"> <img src="language-logos/haskell.svg"/>Haskell </a> <a href="https://github.com/testcontainers/testcontainers-ruby/" class="card-grid-item" ><img src="language-logos/ruby.svg"/>Ruby</a> </div> <h2 id="about">About</h2> <p>Testcontainers for .NET is a library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions. The library is built on top of the .NET Docker remote API and provides a lightweight implementation to support your test environment in all circumstances.</p> <p>Choose from existing pre-configured modules and start containers within a second, to support and run your tests. Or create your own container images with Dockerfiles and run your containers and tests immediately afterward.</p> <p>For more detailed instructions and guidance, please refer to the Testcontainers' <a href="https://testcontainers.com/guides/introducing-testcontainers/">Getting Started</a> guide. If you are specifically interested in using Testcontainers for .NET, you find a dedicated follow-up guide <a href="https://testcontainers.com/guides/getting-started-with-testcontainers-for-dotnet/">here</a>. These resources will provide you with comprehensive information to help you get started and make the most out of Testcontainers.</p> <h2 id="supported-operating-systems">Supported operating systems</h2> <p>Testcontainers supports Windows, Linux, and macOS as host systems. Linux Docker containers are supported on all three operating systems. Native Windows Docker containers are only supported on Windows. Windows requires the host operating system version to match the container operating system version. You will find further information about Windows container version compatibility <a href="https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility">here</a>.</p> <p>With Docker Desktop you can switch the engine either with the tray icon context menu or: <code>$env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon</code> or <code>-SwitchLinuxEngine</code>, <code>-SwitchWindowsEngine</code>.</p> <h2 id="system-requirements">System requirements</h2> <p>Testcontainers requires a Docker-API compatible container runtime. During development, Testcontainers is actively tested against recent versions of Docker on Linux, as well as against Docker Desktop on Mac and Windows. These Docker environments are automatically detected and used by Testcontainers without any additional configuration being necessary.</p> <p>It is possible to configure Testcontainers to work for other Docker setups, such as a remote Docker host or Docker alternatives. However, these are not actively tested in the main development workflow, so not all Testcontainers features might be available and additional manual configuration might be necessary. If you have further questions about configuration details for your setup or whether it supports running Testcontainers-based tests, please contact the Testcontainers team and other users from the Testcontainers community on <a href="https://slack.testcontainers.org/">Slack</a>.</p> <h2 id="license">License</h2> <p>See <a href="https://raw.githubusercontent.com/testcontainers/testcontainers-dotnet/main/LICENSE">LICENSE</a>.</p> <h2 id="copyright">Copyright</h2> <p>Copyright (c) 2019 - 2025 Andre Hofmeister and other authors.</p> <p>See <a href="https://github.com/testcontainers/testcontainers-dotnet/graphs/contributors/">contributors</a> for all contributors.</p> <hr /> <p>Join our <a href="https://slack.testcontainers.org/">Slack workspace</a> | <a href="https://www.testcontainers.org/">Testcontainers OSS</a> | <a href="https://www.testcontainers.cloud/">Testcontainers Cloud</a></p> </article> </div> </div> </main> <footer class="md-footer"> <nav class="md-footer__inner md-grid" aria-label="Footer" > <a href="cicd/" class="md-footer__link md-footer__link--next" aria-label="Next: Continuous Integration" rel="next"> <div class="md-footer__title"> <div class="md-ellipsis"> <span class="md-footer__direction"> Next </span> Continuous Integration </div> </div> <div class="md-footer__button md-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"/></svg> </div> </a> </nav> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class="md-copyright"> Made with <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener"> Material for MkDocs </a> </div> </div> </div> </footer> </div> <div class="md-dialog" data-md-component="dialog"> <div class="md-dialog__inner md-typeset"></div> </div> <script id="__config" type="application/json">{"base": ".", "features": [], "search": "assets/javascripts/workers/search.16e2a7d4.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version.title": "Select version"}}</script> <script src="assets/javascripts/bundle.5a2dcb6a.min.js"></script> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10