public TemporaryContainerManager(DockerClientManager clientManager, TimeSpan maxContainerAge, ILogger logger)
        {
            _clientManager   = clientManager;
            _maxContainerAge = maxContainerAge;
            _logger          = logger;

            _destructionTask = Task.Run(RunDestructionLoop);
        }
        public TriceratopsDockerClient(Uri dockerDaemonUri, ILoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger <ITriceratopsDockerClient>();

            _clientManager             = new DockerClientManager(dockerDaemonUri, loggerFactory);
            _temporaryContainerManager = new TemporaryContainerManager(
                _clientManager,
                TimeSpan.FromMinutes(2),
                loggerFactory.CreateLogger <TemporaryContainerManager>()
                );

            PrepareAsync().Wait();
        }
Ejemplo n.º 3
0
        public static async Task<bool> WaitForContainerToStopAsync(
            string containerId,
            DockerClientManager clientManager,
            ILogger logger
        )
        {
            return await RetryHelper.RetryTask(async r =>
            {
                var response = await clientManager.InspectContainerAsync(containerId);

                if (!response.DockerResponse.State.Running)
                {
                    return true;
                }

                logger.LogInformation($"Waiting for container {containerId} to stop (retry {r})");

                return false;
            }, 30, TimeSpan.FromSeconds(1));
        }