content/reference/api/extensions-sdk/DockerDesktopClient.md
An amalgam of the v0 and v1 interfaces of the Docker Desktop API client, provided for backwards compatibility reasons. Unless you're working with a legacy extension, use the v1 type instead.
• Readonly backend: undefined | BackendV0
The window.ddClient.backend object can be used to communicate with the backend defined in the vm section of
the extension metadata.
The client is already connected to the backend.
[!WARNING]
It will be removed in a future version. Use extension instead.
DockerDesktopClientV0.backend
• Readonly extension: Extension
The ddClient.extension object can be used to communicate with the backend defined in the vm section of the
extension metadata.
The client is already connected to the backend.
DockerDesktopClientV1.extension
• Readonly desktopUI: DesktopUI
DockerDesktopClientV1.desktopUI
• Readonly host: Host
DockerDesktopClientV1.host
• Readonly docker: Docker
DockerDesktopClientV1.docker
▸ listContainers(options): Promise<unknown>
Get the list of running containers (same as docker ps).
By default, this will not list stopped containers.
You can use the option {"all": true} to list all the running and stopped containers.
const containers = await window.ddClient.listContainers();
[!WARNING]
It will be removed in a future version. Use listContainers instead.
| Name | Type | Description |
|---|---|---|
options | never | (Optional). A JSON like { "all": true, "limit": 10, "size": true, "filters": JSON.stringify({ status: ["exited"] }), } For more information about the different properties see the Docker API endpoint documentation. |
Promise<unknown>
DockerDesktopClientV0.listContainers
▸ listImages(options): Promise<unknown>
Get the list of images
const images = await window.ddClient.listImages();
[!WARNING]
It will be removed in a future version. Use listImages instead.
| Name | Type | Description |
|---|---|---|
options | never | (Optional). A JSON like { "all": true, "filters": JSON.stringify({ dangling: ["true"] }), "digests": true } For more information about the different properties see the Docker API endpoint documentation. |
Promise<unknown>
DockerDesktopClientV0.listImages
▸ navigateToContainers(): void
Navigate to the container's window in Docker Desktop.
window.ddClient.navigateToContainers();
[!WARNING]
It will be removed in a future version. Use viewContainers instead.
void
DockerDesktopClientV0.navigateToContainers
▸ navigateToContainer(id): Promise<any>
Navigate to the container window in Docker Desktop.
await window.ddClient.navigateToContainer(id);
[!WARNING]
It will be removed in a future version.
| Name | Type | Description |
|---|---|---|
id | string | The full container id, e.g. 46b57e400d801762e9e115734bf902a2450d89669d85881058a46136520aca28. You can use the --no-trunc flag as part of the docker ps command to display the full container id. |
Promise<any>
A promise that fails if the container doesn't exist.
DockerDesktopClientV0.navigateToContainer
▸ navigateToContainerLogs(id): Promise<any>
Navigate to the container logs window in Docker Desktop.
await window.ddClient.navigateToContainerLogs(id);
[!WARNING]
It will be removed in a future version.
| Name | Type | Description |
|---|---|---|
id | string | The full container id, e.g. 46b57e400d801762e9e115734bf902a2450d89669d85881058a46136520aca28. You can use the --no-trunc flag as part of the docker ps command to display the full container id. |
Promise<any>
A promise that fails if the container doesn't exist.
DockerDesktopClientV0.navigateToContainerLogs
▸ navigateToContainerInspect(id): Promise<any>
Navigate to the container inspect window in Docker Desktop.
await window.ddClient.navigateToContainerInspect(id);
[!WARNING]
It will be removed in a future version.
| Name | Type | Description |
|---|---|---|
id | string | The full container id, e.g. 46b57e400d801762e9e115734bf902a2450d89669d85881058a46136520aca28. You can use the --no-trunc flag as part of the docker ps command to display the full container id. |
Promise<any>
A promise that fails if the container doesn't exist.
DockerDesktopClientV0.navigateToContainerInspect
▸ navigateToContainerStats(id): Promise<any>
Navigate to the container stats to see the CPU, memory, disk read/write and network I/O usage.
await window.ddClient.navigateToContainerStats(id);
[!WARNING]
It will be removed in a future version.
| Name | Type | Description |
|---|---|---|
id | string | The full container id, e.g. 46b57e400d801762e9e115734bf902a2450d89669d85881058a46136520aca28. You can use the --no-trunc flag as part of the docker ps command to display the full container id. |
Promise<any>
A promise that fails if the container doesn't exist.
DockerDesktopClientV0.navigateToContainerStats
▸ navigateToImages(): void
Navigate to the images window in Docker Desktop.
await window.ddClient.navigateToImages(id);
[!WARNING]
It will be removed in a future version. Use viewImages instead.
void
DockerDesktopClientV0.navigateToImages
▸ navigateToImage(id, tag): Promise<any>
Navigate to a specific image referenced by id and tag in Docker Desktop.
In this navigation route you can find the image layers, commands, created time and size.
await window.ddClient.navigateToImage(id, tag);
[!WARNING]
It will be removed in a future version. Use viewImage instead.
| Name | Type | Description |
|---|---|---|
id | string | The full image id (including sha), e.g. sha256:34ab3ae068572f4e85c448b4035e6be5e19cc41f69606535cd4d768a63432673. |
tag | string | The tag of the image, e.g. latest, 0.0.1, etc. |
Promise<any>
A promise that fails if the container doesn't exist.
DockerDesktopClientV0.navigateToImage
▸ navigateToVolumes(): void
Navigate to the volumes window in Docker Desktop.
await window.ddClient.navigateToVolumes();
[!WARNING]
It will be removed in a future version. Use viewVolumes instead.
void
DockerDesktopClientV0.navigateToVolumes
▸ navigateToVolume(volume): void
Navigate to a specific volume in Docker Desktop.
window.ddClient.navigateToVolume(volume);
[!WARNING]
It will be removed in a future version. Use viewVolume instead.
| Name | Type | Description |
|---|---|---|
volume | string | The name of the volume, e.g. my-volume. |
void
DockerDesktopClientV0.navigateToVolume
▸ execHostCmd(cmd): Promise<ExecResultV0>
Invoke a binary on the host. The binary is typically shipped with your extension using the host section in the extension metadata. Note that extensions run with user access rights, this API is not restricted to binaries listed in the host section of the extension metadata (some extensions might install software during user interaction, and invoke newly installed binaries even if not listed in the extension metadata)
window.ddClient.execHostCmd(`cliShippedOnHost xxx`).then((cmdResult: any) => {
console.log(cmdResult);
});
[!WARNING]
It will be removed in a future version. Use exec instead.
| Name | Type | Description |
|---|---|---|
cmd | string | The command to be executed. |
Promise<ExecResultV0>
DockerDesktopClientV0.execHostCmd
▸ spawnHostCmd(cmd, args, callback): void
Invoke an extension binary on your host and get the output stream.
window.ddClient.spawnHostCmd(
`cliShippedOnHost`,
[`arg1`, `arg2`],
(data: any, err: any) => {
console.log(data.stdout, data.stderr);
// Once the command exits we get the status code
if (data.code) {
console.log(data.code);
}
}
);
[!WARNING]
It will be removed in a future version. Use exec instead.
| Name | Type | Description |
|---|---|---|
cmd | string | The command to be executed. |
args | string[] | The arguments of the command to execute. |
callback | (data: any, error: any) => void | The callback function where to listen from the command output data and errors. |
void
DockerDesktopClientV0.spawnHostCmd
▸ execDockerCmd(cmd, ...args): Promise<ExecResultV0>
You can also directly execute the Docker binary.
const output = await window.ddClient.execDockerCmd("info");
[!WARNING]
It will be removed in a future version. Use exec instead.
| Name | Type | Description |
|---|---|---|
cmd | string | The command to execute. |
...args | string[] | The arguments of the command to execute. |
Promise<ExecResultV0>
The result will contain both the standard output and the standard error of the executed command:
{
"stderr": "...",
"stdout": "..."
}
For convenience, the command result object also has methods to easily parse it depending on the output format:
output.lines(): string[] splits output lines.output.parseJsonObject(): any parses a well-formed JSON output.output.parseJsonLines(): any[] parses each output line as a JSON object.If the output of the command is too long, or you need to get the output as a stream you can use the
window.ddClient.spawnDockerCmd("logs", ["-f", "..."], (data, error) => {
console.log(data.stdout);
});
DockerDesktopClientV0.execDockerCmd
▸ spawnDockerCmd(cmd, args, callback): void
[!WARNING]
It will be removed in a future version. Use exec instead.
| Name | Type |
|---|---|
cmd | string |
args | string[] |
callback | (data: any, error: any) => void |
void
DockerDesktopClientV0.spawnDockerCmd
▸ openExternal(url): void
Opens an external URL with the system default browser.
window.ddClient.openExternal("https://docker.com");
[!WARNING]
It will be removed in a future version. Use openExternal instead.
| Name | Type | Description |
|---|---|---|
url | string | The URL the browser opens (must have the protocol http or https). |
void
DockerDesktopClientV0.openExternal
▸ toastSuccess(msg): void
Display a toast message of type success.
window.ddClient.toastSuccess("message");
Warning`
It will be removed in a future version. Use success instead.
| Name | Type | Description |
|---|---|---|
msg | string | The message to display in the toast. |
void
DockerDesktopClientV0.toastSuccess
▸ toastWarning(msg): void
Display a toast message of type warning.
window.ddClient.toastWarning("message");
[!WARNING]
It will be removed in a future version. Use warning instead.
| Name | Type | Description |
|---|---|---|
msg | string | The message to display in the toast. |
void
DockerDesktopClientV0.toastWarning
▸ toastError(msg): void
Display a toast message of type error.
window.ddClient.toastError("message");
[!WARNING]
It will be removed in a future version. Use error instead.
| Name | Type | Description |
|---|---|---|
msg | string | The message to display in the toast. |
void
DockerDesktopClientV0.toastError