@hallmaster/docker.js 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +60 -0
  2. package/package.json +6 -1
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Docker.js
2
+
3
+ This repository is heavily used for the Hallmaster project, that you can check
4
+ out [right here](https://github.com/hallmasterorg/hallmaster).
5
+
6
+ It is a library used to manipulate Docker containers, images and all interfaces
7
+ that can be managed by the Docker Engine.
8
+
9
+ ## How to use
10
+
11
+ The entrypoint of this library is the `DockerSocket` object. It has to be
12
+ instantiated given a UNIX socket (the one used by the Docker Engine) as well as
13
+ the API hostname.
14
+
15
+ ```typescript
16
+ // index.ts
17
+ import { DockerSocket } from "@hallmaster/docker.js";
18
+
19
+ (async function () {
20
+ const socket = new DockerSocket();
21
+
22
+ await socket.init(); // prepare the UNIX socket to be used
23
+
24
+ // if you want, you may authenticate to a Docker Image registry
25
+ // await socket.authenticate(
26
+ // "ghcr.io",
27
+ // "github_username",
28
+ // "github_pat",
29
+ // );
30
+ // console.log(socket.token);
31
+
32
+ // you can get the information of the API from the socket such as the version
33
+ // of the Docker Engine
34
+ console.log(await socket.info());
35
+ })();
36
+ ```
37
+
38
+ Once you have instantiated the `DockerSocket` object and initialized it with the
39
+ `init()` method, you are ready to use it everywhere.
40
+
41
+ For instance, to fetch data from containers, you may use this snippet :
42
+
43
+ ```typescript
44
+ import { DockerContainer } from "@hallmaster/docker.js";
45
+
46
+ (async function() {
47
+ // ...
48
+
49
+ const containerApi = new DockerContainer(dockerSocket);
50
+
51
+ const containers = await containerApi.list();
52
+ for (const container of containers) {
53
+ const containerLogs = await containerApi.logs(container.Id);
54
+ console.log("-----------");
55
+ console.log(`Logs for the container #${container.Id}`);
56
+ console.log(containerLogs);
57
+ console.log("-----------");
58
+ }
59
+ })();
60
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hallmaster/docker.js",
3
3
  "description": "A TypeScript Docker API wrapper mainly used for the Hallmaster project.",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "private": false,
@@ -15,10 +15,15 @@
15
15
  "dist"
16
16
  ],
17
17
  "repository": "github:hallmasterorg/hallmaster-docker-wrapper",
18
+ "homepage": "https://github.com/hallmasterorg/hallmaster-docker-wrapper#readme",
18
19
  "devDependencies": {
19
20
  "@types/node": "^25.0.9",
20
21
  "typescript": "^5.9.3"
21
22
  },
23
+ "keywords": [
24
+ "docker",
25
+ "hallmaster"
26
+ ],
22
27
  "scripts": {
23
28
  "clean": "rm -rf dist",
24
29
  "build": "tsc"