@howdoi-cli/docker 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/data/docker/docker-compose.yaml +46 -0
- package/data/docker/docker.yaml +91 -0
- package/package.json +35 -0
- package/postinstall.mjs +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 howdoi-cli contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @howdoi-cli/docker
|
|
2
|
+
|
|
3
|
+
**howdoi knowledge base — docker commands.**
|
|
4
|
+
|
|
5
|
+
Part of the [howdoi](https://github.com/SiphoChris/howdoi-cli) ecosystem.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @howdoi-cli/docker
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This also installs `@howdoi-cli/core` (the engine and `howdoi` binary) automatically.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
howdoi <what you want to do>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Install more knowledge bases
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g @howdoi-cli/unix
|
|
25
|
+
npm install -g @howdoi-cli/git
|
|
26
|
+
npm install -g @howdoi-cli/ssh
|
|
27
|
+
npm install -g @howdoi-cli/docker
|
|
28
|
+
npm install -g @howdoi-cli/networking
|
|
29
|
+
npm install -g @howdoi-cli/all
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
tool: docker compose
|
|
2
|
+
category: docker
|
|
3
|
+
description: Manage multi-container Docker applications
|
|
4
|
+
package: "@howdoi-cli/docker"
|
|
5
|
+
intents:
|
|
6
|
+
- start docker compose
|
|
7
|
+
- run docker compose
|
|
8
|
+
- stop docker compose
|
|
9
|
+
- restart docker compose services
|
|
10
|
+
- view docker compose logs
|
|
11
|
+
- rebuild docker compose
|
|
12
|
+
- scale docker compose service
|
|
13
|
+
- run command in compose service
|
|
14
|
+
- list compose services
|
|
15
|
+
- remove compose volumes
|
|
16
|
+
examples:
|
|
17
|
+
- intent: start docker compose
|
|
18
|
+
title: Start all services in the background
|
|
19
|
+
command: docker compose up -d
|
|
20
|
+
- intent: start docker compose
|
|
21
|
+
title: Start services and show logs
|
|
22
|
+
command: docker compose up
|
|
23
|
+
- intent: stop docker compose
|
|
24
|
+
title: Stop all running services
|
|
25
|
+
command: docker compose down
|
|
26
|
+
- intent: remove compose volumes
|
|
27
|
+
title: Stop services and remove volumes
|
|
28
|
+
command: docker compose down -v
|
|
29
|
+
- intent: rebuild docker compose
|
|
30
|
+
title: Rebuild images and restart services
|
|
31
|
+
command: docker compose up -d --build
|
|
32
|
+
- intent: view docker compose logs
|
|
33
|
+
title: View logs for all services
|
|
34
|
+
command: docker compose logs
|
|
35
|
+
- intent: view docker compose logs
|
|
36
|
+
title: Follow logs for a specific service
|
|
37
|
+
command: docker compose logs -f service_name
|
|
38
|
+
- intent: run command in compose service
|
|
39
|
+
title: Run a command inside a running service
|
|
40
|
+
command: docker compose exec service_name bash
|
|
41
|
+
- intent: restart docker compose services
|
|
42
|
+
title: Restart a specific service
|
|
43
|
+
command: docker compose restart service_name
|
|
44
|
+
- intent: list compose services
|
|
45
|
+
title: List all services and their status
|
|
46
|
+
command: docker compose ps
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
tool: docker
|
|
2
|
+
category: docker
|
|
3
|
+
description: Manage Docker containers, images, and volumes
|
|
4
|
+
package: "@howdoi-cli/docker"
|
|
5
|
+
intents:
|
|
6
|
+
- run docker container
|
|
7
|
+
- start container
|
|
8
|
+
- stop container
|
|
9
|
+
- list running containers
|
|
10
|
+
- list all containers
|
|
11
|
+
- remove container
|
|
12
|
+
- get shell inside container
|
|
13
|
+
- exec into container
|
|
14
|
+
- view container logs
|
|
15
|
+
- follow container logs
|
|
16
|
+
- inspect container
|
|
17
|
+
- restart container
|
|
18
|
+
- remove all stopped containers
|
|
19
|
+
- list docker images
|
|
20
|
+
- pull docker image
|
|
21
|
+
- remove docker image
|
|
22
|
+
- build docker image
|
|
23
|
+
- tag docker image
|
|
24
|
+
- push docker image
|
|
25
|
+
- run container in background
|
|
26
|
+
- map port in docker
|
|
27
|
+
- mount volume in docker
|
|
28
|
+
- pass environment variable to container
|
|
29
|
+
- copy file from container
|
|
30
|
+
- copy file to container
|
|
31
|
+
examples:
|
|
32
|
+
- intent: list running containers
|
|
33
|
+
title: List all running containers
|
|
34
|
+
command: docker ps
|
|
35
|
+
- intent: list all containers
|
|
36
|
+
title: List all containers including stopped ones
|
|
37
|
+
command: docker ps -a
|
|
38
|
+
- intent: run docker container
|
|
39
|
+
title: Run a container interactively
|
|
40
|
+
command: docker run -it ubuntu bash
|
|
41
|
+
- intent: run container in background
|
|
42
|
+
title: Run a container in the background (detached)
|
|
43
|
+
command: docker run -d nginx
|
|
44
|
+
- intent: map port in docker
|
|
45
|
+
title: Run container and map host port to container port
|
|
46
|
+
command: docker run -p 8080:80 nginx
|
|
47
|
+
- intent: pass environment variable to container
|
|
48
|
+
title: Run container with environment variables
|
|
49
|
+
command: docker run -e NODE_ENV=production -e PORT=3000 myapp
|
|
50
|
+
- intent: mount volume in docker
|
|
51
|
+
title: Mount a local directory into a container
|
|
52
|
+
command: docker run -v $(pwd):/app node:18
|
|
53
|
+
- intent: get shell inside container
|
|
54
|
+
title: Open a bash shell inside a running container
|
|
55
|
+
command: docker exec -it container_name bash
|
|
56
|
+
- intent: view container logs
|
|
57
|
+
title: View logs of a container
|
|
58
|
+
command: docker logs container_name
|
|
59
|
+
- intent: follow container logs
|
|
60
|
+
title: Follow container logs in real time
|
|
61
|
+
command: docker logs -f container_name
|
|
62
|
+
- intent: stop container
|
|
63
|
+
title: Stop a running container
|
|
64
|
+
command: docker stop container_name
|
|
65
|
+
- intent: remove container
|
|
66
|
+
title: Remove a stopped container
|
|
67
|
+
command: docker rm container_name
|
|
68
|
+
- intent: remove all stopped containers
|
|
69
|
+
title: Remove all stopped containers at once
|
|
70
|
+
command: docker container prune
|
|
71
|
+
- intent: list docker images
|
|
72
|
+
title: List all local Docker images
|
|
73
|
+
command: docker images
|
|
74
|
+
- intent: pull docker image
|
|
75
|
+
title: Pull an image from Docker Hub
|
|
76
|
+
command: docker pull node:18
|
|
77
|
+
- intent: build docker image
|
|
78
|
+
title: Build an image from a Dockerfile
|
|
79
|
+
command: docker build -t myapp:latest .
|
|
80
|
+
- intent: remove docker image
|
|
81
|
+
title: Remove a local image
|
|
82
|
+
command: docker rmi myapp:latest
|
|
83
|
+
- intent: copy file from container
|
|
84
|
+
title: Copy a file from a container to your machine
|
|
85
|
+
command: docker cp container_name:/app/file.txt ./file.txt
|
|
86
|
+
- intent: copy file to container
|
|
87
|
+
title: Copy a file from your machine into a container
|
|
88
|
+
command: docker cp ./file.txt container_name:/app/file.txt
|
|
89
|
+
- intent: inspect container
|
|
90
|
+
title: Inspect full container details
|
|
91
|
+
command: docker inspect container_name
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@howdoi-cli/docker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Docker knowledge base for howdoi — containers, images, volumes, and more.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"data",
|
|
8
|
+
"postinstall.mjs",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"postinstall": "node postinstall.mjs",
|
|
14
|
+
"publish:npm": "npm publish"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"howdoi": {
|
|
20
|
+
"type": "knowledge-base",
|
|
21
|
+
"dataDir": "data"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@howdoi-cli/core": "^1.0.0"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18.0.0"
|
|
28
|
+
},
|
|
29
|
+
"keywords": ["cli", "docker", "containers", "terminal", "howdoi"],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/SiphoChris/howdoi-cli"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cpSync, mkdirSync, existsSync, readFileSync } from "fs";
|
|
3
|
+
import { join, dirname, resolve } from "path";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
|
|
6
|
+
// process.argv[1] is always the path of the running script — reliable across
|
|
7
|
+
// all package managers and working directories
|
|
8
|
+
const scriptDir = dirname(resolve(process.argv[1]));
|
|
9
|
+
const pkgJsonPath = join(scriptDir, "package.json");
|
|
10
|
+
|
|
11
|
+
if (!existsSync(pkgJsonPath)) {
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
|
16
|
+
const pkgName = pkgJson.name.replace("@howdoi-cli/", "");
|
|
17
|
+
|
|
18
|
+
// Skip in monorepo dev context — check for workspace root two levels up
|
|
19
|
+
const monoRootPkg = resolve(scriptDir, "..", "..", "package.json");
|
|
20
|
+
if (existsSync(monoRootPkg)) {
|
|
21
|
+
try {
|
|
22
|
+
const root = JSON.parse(readFileSync(monoRootPkg, "utf-8"));
|
|
23
|
+
if (root.workspaces) {
|
|
24
|
+
console.log(`[howdoi] Dev mode — skipping XDG install for ${pkgJson.name}`);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
} catch { /* continue */ }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const srcData = join(scriptDir, "data");
|
|
31
|
+
if (!existsSync(srcData)) {
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const xdgBase = process.env.XDG_DATA_HOME ?? join(homedir(), ".local", "share");
|
|
36
|
+
const dest = join(xdgBase, "howdoi", pkgName);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
mkdirSync(dest, { recursive: true });
|
|
40
|
+
cpSync(srcData, dest, { recursive: true });
|
|
41
|
+
console.log(`[howdoi] ✓ ${pkgJson.name}@${pkgJson.version} → ${dest}`);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.warn(`[howdoi] Warning: could not copy data: ${err.message}`);
|
|
44
|
+
console.warn(`[howdoi] howdoi will still work via node_modules fallback.`);
|
|
45
|
+
}
|