-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.ts
More file actions
29 lines (23 loc) · 794 Bytes
/
main.ts
File metadata and controls
29 lines (23 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { DockerClient } from './lib/docker-client.js';
import { createWriteStream } from 'node:fs';
import { tmpdir } from 'node:os';
import { Writable } from 'node:stream';
try {
const docker = await DockerClient.fromDockerConfig();
await docker.systemPing();
const v = await docker.systemVersion();
console.dir(v, { depth: null });
const ctr = await docker
.containerCreate({
Image: 'alpine',
})
.then((value) => {
console.dir(value, { depth: null });
return value.Id;
});
const out = createWriteStream(tmpdir() + '/test.tar');
await docker.containerExport(ctr, Writable.toWeb(out));
await docker.close();
} catch (error: any) {
console.error(`Error: ${error.message ?? error}`);
}