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}"); } } } }
private async Task RemoveContainerNetworkAsync(IExecutionContext executionContext, string network) { Trace.Entering(); ArgUtil.NotNull(executionContext, nameof(executionContext)); ArgUtil.NotNull(network, nameof(network)); executionContext.Output($"Remove container network: {network}"); int removeExitCode = await _dockerManger.DockerNetworkRemove(executionContext, network); if (removeExitCode != 0) { executionContext.Warning($"Docker network rm failed with exit code {removeExitCode}"); } }