private async Task <string> RunContainerAsync(string rabbitMQDockerImage) { var portMappings = new Dictionary <string, ISet <string> > { { "4369", new HashSet <string>() { "4369" } }, { "5671", new HashSet <string>() { "5671" } }, { "5672", new HashSet <string>() { "5672" } }, { "15671", new HashSet <string>() { "15671" } }, { "15672", new HashSet <string>() { "15672" } }, { "25672", new HashSet <string>() { "25672" } } }; var envVars = new List <string> { $"RABBITMQ_DEFAULT_VHOST={Configuration.RabbitMqVirtualHostName}" }; var containerId = await dockerProxy .CreateContainerAsync(rabbitMQDockerImage, Configuration.RabbitMqHostName, portMappings, dockerNetworkName, envVars) .ConfigureAwait(false); await dockerProxy.StartContainerAsync(containerId).ConfigureAwait(false); return(containerId); }
public async Task InitializeAsync() { dockerEngineOsPlatform = await dockerProxy.GetDockerEngineOsAsync(); dockerNetworkName = dockerEngineOsPlatform == OSPlatform.Windows ? null : "bridgeWhaleNet"; var rabbitMQDockerImage = Configuration.RabbitMQDockerImage(dockerEngineOsPlatform); await DisposeAsync().ConfigureAwait(false); if (dockerEngineOsPlatform == OSPlatform.Linux || dockerEngineOsPlatform == OSPlatform.OSX) { await dockerProxy.CreateNetworkAsync(dockerNetworkName).ConfigureAwait(false); } await dockerProxy.PullImageAsync(rabbitMQDockerImage, RabbitImageTag).ConfigureAwait(false); var portMappings = new Dictionary <string, ISet <string> > { { "4369", new HashSet <string>() { "4369" } }, { "5671", new HashSet <string>() { "5671" } }, { "5672", new HashSet <string>() { "5672" } }, { "15671", new HashSet <string>() { "15671" } }, { "15672", new HashSet <string>() { "15672" } }, { "25672", new HashSet <string>() { "25672" } } }; var envVars = new List <string> { $"RABBITMQ_DEFAULT_VHOST={Configuration.RabbitMqVirtualHostName}" }; var containerId = await dockerProxy .CreateContainerAsync(rabbitMQDockerImage, RabbitContainerAndHostName, portMappings, dockerNetworkName, envVars) .ConfigureAwait(false); await dockerProxy.StartContainerAsync(containerId).ConfigureAwait(false); RabbitContainerHostForManagement = "localhost"; if (dockerEngineOsPlatform == OSPlatform.Windows) { RabbitContainerHostForManagement = await dockerProxy.GetContainerIpAsync(containerId).ConfigureAwait(false); } var timeoutCts = new CancellationTokenSource(TimeSpan.FromSeconds(DefaultTimeoutSeconds)); await WaitForRabbitMqReady(timeoutCts.Token).ConfigureAwait(false); }