當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript dockerode.getContainer函數代碼示例

本文整理匯總了TypeScript中dockerode.getContainer函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getContainer函數的具體用法?TypeScript getContainer怎麽用?TypeScript getContainer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getContainer函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

 containers.forEach(container => {
   docker
     .getContainer(container.Id)
     .stop((err, data) => {
       // NOOP
     });
 });
開發者ID:dphoebus,項目名稱:DefinitelyTyped,代碼行數:7,代碼來源:dockerode-tests.ts

示例2: foo

async function foo() {
  const containers = await docker7.listContainers();
  for (const container of containers) {
    const foo = await docker7.getContainer(container.Id);
    const inspect = await foo.inspect();
  }

  const images = await docker5.listImages();
  for (const image of images) {
    const foo = await docker5.getImage(image.Id);
    const inspect = await foo.inspect();
    await foo.remove();
  }
}
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:14,代碼來源:dockerode-tests.ts

示例3: Docker

  port: process.env.DOCKER_PORT || 2375,
  ca: 'ca',
  cert: 'cert',
  key: 'key'
});

const docker6 = new Docker({
  protocol: 'https', // you can enforce a protocol
  host: '192.168.1.10',
  port: process.env.DOCKER_PORT || 2375,
  ca: 'ca',
  cert: 'cert',
  key: 'key'
});

const container = docker.getContainer('container-id');
container.inspect((err, data) => {
  // NOOP
});

container.start((err, data) => {
  // NOOP
});

container.remove((err, data) => {
  // NOOP
});

docker.listContainers((err, containers) => {
  containers.forEach(container => {
    docker
開發者ID:dphoebus,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:dockerode-tests.ts

示例4:

 return containers.map(container => docker.getContainer(container.Id));
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:1,代碼來源:dockerode-tests.ts

示例5: Docker

"use strict";

import * as Docker from "dockerode";
import log from "./log";

const docker = new Docker();
const container = docker.getContainer("v2ray");

export const init = async () => {
  try {
    const status = await container.inspect();
    if (!status.State.Running) {
      await container.start();
      log.info("docker container v2ray is started");
    } else {
      log.info("docker container v2ray has already been started");
    }
    return status;
  } catch (err) {
    log.error("cannot start docker container v2ray", err);
  }
};

export const reload = async () => {
  try {
    await container.restart();
    log.info("docker container v2ray is restarted");
  } catch (err) {
    log.error("cannot restart docker container v2ray", err);
  }
};
開發者ID:coderfox,項目名稱:Another-SS-Panel,代碼行數:31,代碼來源:docker.ts


注:本文中的dockerode.getContainer函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。