Open
Description
I have some integration tests running on Docker using FluentDocker, version 2.10.59
I am using the NUnit lifecycle to create and destroy instances of a Test Environment.
You can see the implementation of the class 'TestEnvironment':
public sealed class SystemTestEnvironment
{
private SystemTestEnvironment()
{
DockerHost = DockerHelpers.GetDockerHost();
DockerComposeService = Build(DockerHost);
try
{
DockerComposeService.Start();
}
catch(Exception ex)
{
Debug.WriteLine($"[Fluent Docker Error]: {ex} ");
DockerComposeService.Dispose();
throw;
}
OnContainerInitialized();
}
// ... code removed for simplicity
public static void Initialize()
{
Instance = new SystemTestEnvironment();
}
// ... code removed for simplicity
private ICompositeService Build(IHostService dockerHost)
{
return new DockerComposeCompositeService(dockerHost, new DockerComposeConfig
{
ComposeFilePath = new List<string> { SqlServerComposeFile },
ForceRecreate = true,
RemoveOrphans = true,
StopOnDispose = true,
KeepVolumes = false
});
}
}
This is the method GetDockerHost
public static IHostService GetDockerHost()
{
var hosts = new Hosts().Discover();
var defaultHost = hosts.FirstOrDefault(x => x.IsNative) ?? hosts.FirstOrDefault(x => x.Name == "default");
var host = defaultHost ?? (hosts.Count > 0 ? hosts.First() : GetDockerHost());
if (host.State is not ServiceRunningState.Running)
{
host.Start();
}
return host;
}
I am getting the error when I am attempting
DockerComposeService.Dispose();
The code was working previously on Azure DevOps and still works locally.
I use GitHub Actions and workflow for CI
The Github agent has the following Docker Tooling installed:
Docker version 20.10.24+azure-1
docker-compose version 1.29.2