public async Task CreateDockerEnvironment() { // Create the environment using builder pattern var environment = new DockerEnvironmentBuilder() .UseDefaultNetwork() .SetName("test-env") .AddContainer("my-nginx", "nginx") #if DEBUG .AddElasticsearchContainer("my-elastic", ports: new Dictionary <ushort, ushort> { [9200] = 9200 }, reuseContainer: true) .AddMssqlContainer("my-mssql", "HelloK11tt_0", environmentVariables: new Dictionary <string, string> { ["MSSQL_COLLATION"] = "SQL_Latin1_General_CP1_CS_AS" }, reuseContainer: true) .AddMariaDBContainer("my-maria", "my-secret-pw", reuseContainer: true) .AddMongoContainer("my-mongo", reuseContainer: true) .AddMailContainer("my-mail", reuseContainer: true) .AddFtpContainer("my-ftp", "superuser", "test", ports: Enumerable.Range(30000, 10).ToDictionary(p => (ushort)p, p => (ushort)p).MergeDictionaries(new Dictionary <ushort, ushort> { [21] = 21 }), reuseContainer: true) .AddFromDockerfile("from-file", "Dockerfile", containerWaiter: new HttpContainerWaiter("/", httpPort: 8080), reuseContainer: true) .AddPostgresContainer("my-postgres", reuseContainer: true) #else .AddElasticsearchContainer("my-elastic") .AddMssqlContainer("my-mssql", "HelloK11tt_0") .AddMariaDBContainer("my-maria", "my-secret-pw") .AddMongoContainer("my-mongo") .AddMailContainer("my-mail") .AddFromDockerfile("from-file", "Dockerfile", containerWaiter: new HttpContainerWaiter("/", httpPort: 8080)) .AddFtpContainer("my-ftp", "superuser", "test", ports: Enumerable.Range(30000, 10).ToDictionary(p => (ushort)p, p => (ushort)p).MergeDictionaries(new Dictionary <ushort, ushort> { [21] = 21 })) .AddPostgresContainer("my-postgres") #endif .Build(); // Up it. await environment.Up(); // Play with containers. var mssql = environment.GetContainer <MssqlContainer>("my-mssql"); await PrintMssqlVersion(mssql); var elastic = environment.GetContainer <ElasticsearchContainer>("my-elastic"); await PrintElasticsearchVersion(elastic); var mongo = environment.GetContainer <MongoContainer>("my-mongo"); PrintMongoVersion(mongo); var staticFilesContainer = environment.GetContainer("from-file"); await PrintReturnedHtml(staticFilesContainer); var maria = environment.GetContainer <MariaDBContainer>("my-maria"); await PrintMariaDBVersion(maria); var ftp = environment.GetContainer <FtpContainer>("my-ftp"); await PrintFtpServerType(ftp); var mail = environment.GetContainer <MailContainer>("my-mail"); await PrintSmtpCapabilities(mail); var postgres = environment.GetContainer <PostgresContainer>("my-postgres"); await PrintPostgresDbVersion(postgres); #if !DEBUG // Down it. await environment.Down(); // Dispose (remove). await environment.DisposeAsync(); #endif }