Exemple #1
0
        public async Task StopContainerAsync(IExecutionContext executionContext, object data)
        {
            Trace.Entering();
            ArgUtil.NotNull(executionContext, nameof(executionContext));
            ContainerInfo container = data as ContainerInfo;

            ArgUtil.NotNull(container, nameof(container));

            if (!string.IsNullOrEmpty(container.ContainerId))
            {
                executionContext.Output($"Stop container: {container.ContainerDisplayName}");

                int stopExitCode = await _dockerManger.DockerStop(executionContext, container.ContainerId);

                if (stopExitCode != 0)
                {
                    executionContext.Error($"Docker stop fail with exit code {stopExitCode}");
                }

                if (!string.IsNullOrEmpty(container.ContainerNetwork))
                {
                    int removeExitCode = await _dockerManger.DockerNetworkRemove(executionContext, container.ContainerNetwork);

                    if (removeExitCode != 0)
                    {
                        executionContext.Error($"Docker network rm fail with exit code {removeExitCode}");
                    }
                }
            }
        }
Exemple #2
0
        private async Task StopContainerAsync(IExecutionContext executionContext)
        {
            Trace.Entering();
            ArgUtil.NotNull(executionContext, nameof(executionContext));

            if (!string.IsNullOrEmpty(executionContext.Container.ContainerId))
            {
                executionContext.Output($"Stop container: {executionContext.Container.ContainerName}");

                int stopExitCode = await _dockerManger.DockerStop(executionContext, executionContext.Container.ContainerId);
                if (stopExitCode != 0)
                {
                    executionContext.Error($"Docker stop fail with exit code {stopExitCode}");
                }
            }
        }