Interface : DockerDesktopClient
Un amalgame des interfaces v0 et v1 du client API Docker Desktop, fourni pour des raisons de compatibilité ascendante. Sauf si vous travaillez avec une extension héritée, utilisez plutôt le type v1.
Propriétés
backend
• Readonly
backend: undefined
| BackendV0
L'objet window.ddClient.backend
peut être utilisé pour communiquer avec le backend défini dans la section vm
des métadonnées de l'extension.
Le client est déjà connecté au backend.
WarningIl sera supprimé dans une version future. Utilisez extension à la place.
Hérité de
DockerDesktopClientV0.backend
extension
• Readonly
extension: Extension
L'objet ddClient.extension
peut être utilisé pour communiquer avec le backend défini dans la section vm des
métadonnées de l'extension.
Le client est déjà connecté au backend.
Hérité de
DockerDesktopClientV1.extension
desktopUI
• Readonly
desktopUI: DesktopUI
Hérité de
DockerDesktopClientV1.desktopUI
host
• Readonly
host: Host
Hérité de
DockerDesktopClientV1.host
docker
• Readonly
docker: Docker
Hérité de
DockerDesktopClientV1.docker
Méthodes de conteneurs
listContainers
▸ listContainers(options
): Promise
<unknown
>
Obtenir la liste des conteneurs en cours d'exécution (identique à docker ps
).
Par défaut, cela ne listera pas les conteneurs arrêtés.
Vous pouvez utiliser l'option {"all": true}
pour lister tous les conteneurs en cours d'exécution et arrêtés.
const containers = await window.ddClient.listContainers();
WarningIl sera supprimé dans une version future. Utilisez listContainers à la place.
Paramètres
Nom | Type | Description |
---|---|---|
options |
never |
(Optionnel). Un JSON comme { "all": true, "limit": 10, "size": true, "filters": JSON.stringify({ status: ["exited"] }), } Pour plus d'informations sur les différentes propriétés voir la documentation de l'endpoint de l'API Docker. |
Retourne
Promise
<unknown
>
Hérité de
DockerDesktopClientV0.listContainers
Méthodes d'images
listImages
▸ listImages(options
): Promise
<unknown
>
Obtenir la liste des images
const images = await window.ddClient.listImages();
WarningIl sera supprimé dans une version future. Utilisez listImages à la place.
Paramètres
Nom | Type | Description |
---|---|---|
options |
never |
(Optionnel). Un JSON comme { "all": true, "filters": JSON.stringify({ dangling: ["true"] }), "digests": true } Pour plus d'informations sur les différentes propriétés voir la documentation de l'endpoint de l'API Docker. |
Retourne
Promise
<unknown
>
Hérité de
DockerDesktopClientV0.listImages
Méthodes de navigation
navigateToContainers
▸ navigateToContainers(): void
Naviguer vers la fenêtre des conteneurs dans Docker Desktop.
window.ddClient.navigateToContainers();
WarningIl sera supprimé dans une version future. Utilisez viewContainers à la place.
Retourne
void
Hérité de
DockerDesktopClientV0.navigateToContainers
navigateToContainer
▸ navigateToContainer(id
): Promise
<any
>
Naviguer vers la fenêtre du conteneur dans Docker Desktop.
await window.ddClient.navigateToContainer(id);
WarningIl sera supprimé dans une version future.
Paramètres
Nom | Type | Description |
---|---|---|
id |
string |
L'id complet du conteneur, par exemple 46b57e400d801762e9e115734bf902a2450d89669d85881058a46136520aca28 . Vous pouvez utiliser le flag --no-trunc comme partie de la commande docker ps pour afficher l'id complet du conteneur. |
Retourne
Promise
<any
>
Une promesse qui échoue si le conteneur n'existe pas.
Hérité de
DockerDesktopClientV0.navigateToContainer
navigateToContainerLogs
▸ navigateToContainerLogs(id
): Promise
<any
>
Naviguer vers la fenêtre des journaux du conteneur dans Docker Desktop.
await window.ddClient.navigateToContainerLogs(id);
WarningIl sera supprimé dans une version future.
Paramètres
Nom | Type | Description |
---|---|---|
id |
string |
L'id complet du conteneur, par exemple 46b57e400d801762e9e115734bf902a2450d89669d85881058a46136520aca28 . Vous pouvez utiliser le flag --no-trunc comme partie de la commande docker ps pour afficher l'id complet du conteneur. |
Retourne
Promise
<any
>
Une promesse qui échoue si le conteneur n'existe pas.
Hérité de
DockerDesktopClientV0.navigateToContainerLogs
navigateToContainerInspect
▸ navigateToContainerInspect(id
): Promise
<any
>
Naviguer vers la fenêtre d'inspection du conteneur dans Docker Desktop.
await window.ddClient.navigateToContainerInspect(id);
WarningIl sera supprimé dans une version future.
Paramètres
Nom | Type | Description |
---|---|---|
id |
string |
L'id complet du conteneur, par exemple 46b57e400d801762e9e115734bf902a2450d89669d85881058a46136520aca28 . Vous pouvez utiliser le flag --no-trunc comme partie de la commande docker ps pour afficher l'id complet du conteneur. |
Retourne
Promise
<any
>
Une promesse qui échoue si le conteneur n'existe pas.
Hérité de
DockerDesktopClientV0.navigateToContainerInspect
navigateToContainerStats
▸ 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);
WarningIt will be removed in a future version.
Parameters
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. |
Returns
Promise
<any
>
A promise that fails if the container doesn't exist.
Inherited from
DockerDesktopClientV0.navigateToContainerStats
navigateToImages
▸ navigateToImages(): void
Navigate to the images window in Docker Desktop.
await window.ddClient.navigateToImages(id);
WarningIt will be removed in a future version. Use viewImages instead.
Returns
void
Inherited from
DockerDesktopClientV0.navigateToImages
navigateToImage
▸ 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);
WarningIt will be removed in a future version. Use viewImage instead.
Parameters
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. |
Returns
Promise
<any
>
A promise that fails if the container doesn't exist.
Inherited from
DockerDesktopClientV0.navigateToImage
navigateToVolumes
▸ navigateToVolumes(): void
Navigate to the volumes window in Docker Desktop.
await window.ddClient.navigateToVolumes();
WarningIt will be removed in a future version. Use viewVolumes instead.
Returns
void
Inherited from
DockerDesktopClientV0.navigateToVolumes
navigateToVolume
▸ navigateToVolume(volume
): void
Navigate to a specific volume in Docker Desktop.
window.ddClient.navigateToVolume(volume);
WarningIt will be removed in a future version. Use viewVolume instead.
Parameters
Name | Type | Description |
---|---|---|
volume |
string |
The name of the volume, e.g. my-volume . |
Returns
void
Inherited from
DockerDesktopClientV0.navigateToVolume
Other Methods
execHostCmd
▸ execHostCmd(cmd
): Promise
<ExecResultV0
>
You can run binaries defined in the host section in the extension metadata.
window.ddClient.execHostCmd(`cliShippedOnHost xxx`).then((cmdResult: any) => {
console.log(cmdResult);
});
WarningIt will be removed in a future version. Use exec instead.
Parameters
Name | Type | Description |
---|---|---|
cmd |
string |
The command to be executed. |
Returns
Promise
<ExecResultV0
>
Inherited from
DockerDesktopClientV0.execHostCmd
spawnHostCmd
▸ 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);
}
}
);
WarningIt will be removed in a future version. Use exec instead.
Parameters
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. |
Returns
void
Inherited from
DockerDesktopClientV0.spawnHostCmd
execDockerCmd
▸ execDockerCmd(cmd
, ...args
): Promise
<ExecResultV0
>
You can also directly execute the Docker binary.
const output = await window.ddClient.execDockerCmd("info");
WarningIt will be removed in a future version. Use exec instead.
Parameters
Name | Type | Description |
---|---|---|
cmd |
string |
The command to execute. |
...args |
string [] |
The arguments of the command to execute. |
Returns
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
- spawnDockerCmd function:
window.ddClient.spawnDockerCmd("logs", ["-f", "..."], (data, error) => {
console.log(data.stdout);
});
Inherited from
DockerDesktopClientV0.execDockerCmd
spawnDockerCmd
▸ spawnDockerCmd(cmd
, args
, callback
): void
WarningIt will be removed in a future version. Use exec instead.
Parameters
Name | Type |
---|---|
cmd |
string |
args |
string [] |
callback |
(data : any , error : any ) => void |
Returns
void
Inherited from
DockerDesktopClientV0.spawnDockerCmd
openExternal
▸ openExternal(url
): void
Opens an external URL with the system default browser.
window.ddClient.openExternal("https://docker.com");
WarningIt will be removed in a future version. Use openExternal instead.
Parameters
Name | Type | Description |
---|---|---|
url |
string |
The URL the browser opens (must have the protocol http or https ). |
Returns
void
Inherited from
DockerDesktopClientV0.openExternal
Toast Methods
toastSuccess
▸ 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.
Parameters
Name | Type | Description |
---|---|---|
msg |
string |
The message to display in the toast. |
Returns
void
Inherited from
DockerDesktopClientV0.toastSuccess
toastWarning
▸ toastWarning(msg
): void
Display a toast message of type warning.
window.ddClient.toastWarning("message");
WarningIt will be removed in a future version. Use warning instead.
Parameters
Name | Type | Description |
---|---|---|
msg |
string |
The message to display in the toast. |
Returns
void
Inherited from
DockerDesktopClientV0.toastWarning
toastError
▸ toastError(msg
): void
Display a toast message of type error.
window.ddClient.toastError("message");
WarningIt will be removed in a future version. Use error instead.
Parameters
Name | Type | Description |
---|---|---|
msg |
string |
The message to display in the toast. |
Returns
void
Inherited from
DockerDesktopClientV0.toastError