本文整理汇总了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);
}
};