https://github.com/nonebot/cli-plugin-docker
docker support for nb-cli
https://github.com/nonebot/cli-plugin-docker
Last synced: about 1 month ago
JSON representation
docker support for nb-cli
- Host: GitHub
- URL: https://github.com/nonebot/cli-plugin-docker
- Owner: nonebot
- License: mit
- Created: 2023-01-09T08:08:28.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2025-12-03T09:09:14.000Z (3 months ago)
- Last Synced: 2025-12-06T11:28:48.508Z (3 months ago)
- Language: Python
- Size: 188 KB
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NB CLI Plugin Docker
_✨ NoneBot2 命令行工具 Docker 插件 ✨_
## 准备
在使用本插件前请确保 Docker CLI 以及 Docker Compose Plugin 已经安装,且可以从命令行直接使用。
详细安装方法请参考 [Docker 文档](https://docs.docker.com/engine/install/)
Docker 官方 Linux 快速安装一键脚本:
```bash
curl -fsSL https://get.docker.com | sudo sh
```
## 安装插件
### uv tool / uvx(推荐)
首先需要[安装 uv](https://docs.astral.sh/uv/#installation)。
直接使用:
```bash
uvx --from nb-cli --with nb-cli-plugin-docker nb docker
# 或
uv tool run --from nb-cli --with nb-cli-plugin-docker nb docker
```
安装:
```bash
uv tool install --with nb-cli-plugin-docker nb-cli
# 更新环境变量(如果需要)
uv tool update-shell
```
### 通用方式
```bash
nb self install nb-cli-plugin-docker
```
## 使用插件
```bash
nb docker
# 其他别名
# nb deploy
# nb compose
```
### generate
生成 `Dockerfile` 和 `docker-compose.yml`。
#### 什么时候需要(重新)生成?
- 在项目中首次使用本插件时;
- 更换了机器人项目的管理器时。
#### 传递项目依赖
对于使用了 `uv`, `pdm` 或 `poetry` 的机器人项目,本插件会自动检查相应的依赖固定信息(即 `*.lock` 文件)判断并调用相应工具自动向容器内传递依赖。
对于其他管理方式的机器人项目,则需要手动导出一份 `requirements.txt` 来传递项目依赖到容器内,例如:
```bash
source .venv/bin/activate
pip freeze > requirements.txt
```
### build
构建机器人镜像。
### up / down
部署/取消部署机器人实例。
### logs
查看机器人日志。
### ps
查看机器人运行状态。
