MCPcopy Create free account
hub / github.com/devcontainers/cli / listContainers

Function listContainers

src/spec-shutdown/dockerUtils.ts:158–171  ·  view source on GitHub ↗
(params: DockerCLIParameters | PartialExecParameters | DockerResolverParameters, all = false, labels: string[] = [])

Source from the content-addressed store, hash-verified

156}
157
158export async function listContainers(params: DockerCLIParameters | PartialExecParameters | DockerResolverParameters, all = false, labels: string[] = []) {
159 const filterArgs = [];
160 if (all) {
161 filterArgs.push('-a');
162 }
163 for (const label of labels) {
164 filterArgs.push('--filter', `label=${label}`);
165 }
166 const result = await dockerCLI(params, 'ps', '-q', ...filterArgs);
167 return result.stdout
168 .toString()
169 .split(/\r?\n/)
170 .filter(s => !!s);
171}
172
173export async function removeContainer(params: DockerCLIParameters | PartialExecParameters | DockerResolverParameters, nameOrId: string) {
174 const useEvents = !('cliVariant' in params && params.cliVariant === CLIVariant.Wslc);

Callers 6

testRemoveContainerFunction · 0.90
findComposeContainerFunction · 0.90
findDevContainerFunction · 0.90
pollFunction · 0.90

Calls 1

dockerCLIFunction · 0.85

Tested by 1

testRemoveContainerFunction · 0.72