public static CommandResponse <IList <string> > ComposeDown(this DockerUri host, string altProjectName = null, ImageRemovalOption removeImagesFrom = ImageRemovalOption.None, bool removeVolumes = false, bool removeOrphanContainers = false, IDictionary <string, string> env = null, ICertificatePaths certificates = null, params string[] composeFile) { var cwd = WorkingDirectory(composeFile); var args = $"{host.RenderBaseArgs(certificates)}"; if (null != composeFile && 0 != composeFile.Length) { foreach (var cf in composeFile) { if (!string.IsNullOrEmpty(cf)) { args += $" -f \"{cf}\""; } } } if (!string.IsNullOrEmpty(altProjectName)) { args += $" -p {altProjectName}"; } var options = string.Empty; if (removeOrphanContainers) { options += " --remove-orphans"; } if (removeVolumes) { options += " -v"; } if (removeImagesFrom != ImageRemovalOption.None) { options += removeImagesFrom == ImageRemovalOption.Local ? " --rmi local" : " --rmi all"; } return (new ProcessExecutor <StringListResponseParser, IList <string> >( "docker-compose".ResolveBinary(), $"{args} down {options}", cwd.NeedCwd ? cwd.Cwd : null).ExecutionEnvironment(env).Execute()); }
public static CommandResponse <IList <string> > ComposeDown(this DockerUri host, string altProjectName = null, string composeFile = null, ImageRemovalOption removeImagesFrom = ImageRemovalOption.None, bool removeVolumes = false, bool removeOrphanContainers = false, ICertificatePaths certificates = null) { var args = $"{host.RenderBaseArgs(certificates)}"; if (!string.IsNullOrEmpty(composeFile)) { args += $" -f {composeFile}"; } if (!string.IsNullOrEmpty(altProjectName)) { args += $" -p {altProjectName}"; } var options = string.Empty; if (removeOrphanContainers) { options += " --remove-orphans"; } if (removeVolumes) { options += " -v"; } if (removeImagesFrom != ImageRemovalOption.None) { options += removeImagesFrom == ImageRemovalOption.Local ? " --rmi local" : " --rmi type all"; } return (new ProcessExecutor <StringListResponseParser, IList <string> >( "docker-compose".ResolveBinary(), $"{args} down {options}").Execute()); }