Docker (original) (raw)

listContainers(options?): Promise<unknown>

To get the list of containers:

listImages(options?): Promise<unknown>

To get the list of local container images:

See theDocker API reference for details about these methods.

Deprecated access to Docker objects

The methods below are deprecated and will be removed in a future version. Use the methods specified above.

Extensions can also directly execute the docker command line.

exec(cmd, args): Promise<ExecResult>

The result contains both the standard output and the standard error of the executed command:

In this example, the command output is JSON. For convenience, the command result object also has methods to easily parse it:

exec(cmd, args, options): void

The command above streams the output as a result of the execution of a Docker command. This is useful if you need to get the output as a stream or the output of the command is too long.

The child process created by the extension is killed (SIGTERM) automatically when you close the dashboard in Docker Desktop or when you exit the extension UI. If needed, you can also use the result of the exec(streamOptions) call in order to kill (SIGTERM) the process.

This exec(streamOptions) API can also be used to listen to docker events:

You cannot use this to chain commands in a single exec() invocation (like docker kill $(docker ps -q) or using pipe between commands).

You need to invoke exec() for each command and parse results to pass parameters to the next command if needed.

See theExec API reference for details about these methods.

Deprecated execution of Docker commands

This method is deprecated and will be removed in a future version. Use the one specified just below.