-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.md
57 lines (43 loc) · 1004 Bytes
/
README.md
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Nerdctl
Node wrapper for nerdctl
# Install
```shell
yarn add nerdctl
```
# Useage
```ts
import { events, factory } from "nerdctl";
const IMAGE_NAME = "hello-world";
const CONTAINER_NAME = "hello";
const vm = factory();
vm.on(events.VM_INIT_START, () => {
console.log("VM_INIT_START");
});
vm.on(events.VM_INIT_OUTPUT, (data) => {
console.log(data);
});
vm.on(events.VM_INIT_END, () => {
console.log("VM_INIT_END");
});
vm.on(events.IMAGE_PULL_START, () => {});
vm.on(events.IMAGE_PULL_OUTPUT, (data) => {
console.log(data);
});
vm.on(events.IMAGE_PULL_END, (data) => {
console.log(data);
});
vm.on(events.CONTAINER_RUN_OUTPUT, (data) => {
console.log(data);
});
if (!(await vm.checkVM())) {
await vm.initVM();
}
await vm.pullImage(IMAGE_NAME);
const images = await vm.getImages();
console.log(images);
await vm.run(IMAGE_NAME, { name: CONTAINER_NAME });
await vm.stop(CONTAINER_NAME);
await vm.remove(CONTAINER_NAME);
```
## License
Node nerdctl is [MIT licensed](LICENSE).