本文整理汇总了TypeScript中dockerode.buildImage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript buildImage函数的具体用法?TypeScript buildImage怎么用?TypeScript buildImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了buildImage函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: buildDocker
async function buildDocker(dir: string, tag: string): Promise<{}> {
const tarStream = tar.pack(dir);
const stream = await DOCKER.buildImage(tarStream, {t: tag});
let resolve: (output: {}) => void;
let reject: (err: Error) => void;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
function onFinished(err: Error, output: {}) {
if (err) {
return reject(err);
}
resolve(output);
}
function onProgress(
event: {stream?: string; status?: string; progress?: string;}) {
log(event.stream);
log(event.status);
log(event.progress);
}
DOCKER.modem.followProgress(stream, onFinished, onProgress);
return promise;
}
示例2:
// NOOP
});
container.start((err, data) => {
// NOOP
});
container.remove((err, data) => {
// NOOP
});
docker.listContainers((err, containers) => {
containers.forEach(container => {
docker
.getContainer(container.Id)
.stop((err, data) => {
// NOOP
});
});
});
docker.buildImage('archive.tar', { t: 'imageName' }, (err, response) => {
// NOOP
});
docker.createContainer({ Tty: true }, (err, container) => {
container.start((err, data) => {
// NOOP
});
});
示例3:
docker.listContainers((err, containers) => {
containers.forEach(container => {
docker
.getContainer(container.Id)
.stop((err, data) => {
// NOOP
});
});
});
docker.listContainers().then(containers => {
return containers.map(container => docker.getContainer(container.Id));
});
docker.buildImage('archive.tar', { t: 'imageName' }, (err, response) => {
// NOOP
});
docker.buildImage({context: '.', src: ['Dockerfile', 'test.sh']}, { t: 'imageName' }, (err, response) => {
// NOOP
});
docker.createContainer({ Tty: true }, (err, container) => {
container.start((err, data) => {
// NOOP
});
});
docker.pruneContainers((err, response) => {
// NOOP
});