本文整理匯總了TypeScript中dockerode.getContainer函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getContainer函數的具體用法?TypeScript getContainer怎麽用?TypeScript getContainer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getContainer函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
containers.forEach(container => {
docker
.getContainer(container.Id)
.stop((err, data) => {
// NOOP
});
});
示例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();
}
}
示例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
示例4:
return containers.map(container => docker.getContainer(container.Id));
示例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);
}
};