实用工具qshell 命令行工具
正在加载文档
最近更新时间: 2026-09-04 17:30:23
沙箱模板用于定义沙箱的基础环境,包括基础镜像、依赖包、文件、启动命令和资源配置。qshell sandbox template 可以完成模板初始化、构建、查询、发布和删除。
qshell sandbox template <子命令>
qshell sbx tpl <子命令>常用子命令:
| 命令 | 说明 |
|---|---|
template init | 初始化模板项目脚手架 |
template list | 列出模板 |
template get | 查看模板详情 |
template build | 创建并构建模板,或重新构建已有模板 |
template builds | 查看模板构建状态 |
template publish | 发布模板 |
template unpublish | 取消发布模板 |
template delete | 删除模板 |
交互式初始化:
qshell sandbox template init非交互方式初始化 Python 模板:
qshell sandbox template init --name my-python-template --language python --path ./my-python-template初始化 Go 模板:
qshell sandbox template init --name my-go-template --language go初始化 TypeScript 模板:
qshell sandbox template init --name my-ts-template --language typescript支持的语言:
| 语言 | 生成文件 |
|---|---|
python | template.py, requirements.txt |
go | main.go, go.mod, Makefile |
typescript | template.ts, package.json |
从公共镜像构建:
qshell sandbox template build --name python-demo --from-image python:3.11 --wait国内网络环境建议使用镜像代理地址:
qshell sandbox template build \
--name python-demo \
--from-image crp-internal.qiniucs.com/registry-1.docker.io/library/python:3 \
--wait指定资源:
qshell sandbox template build \
--name python-demo \
--from-image crp-internal.qiniucs.com/registry-1.docker.io/library/python:3 \
--cpu 2 \
--memory 2048 \
--wait使用当前目录下的 Dockerfile:
qshell sandbox template build --name my-app --dockerfile ./Dockerfile --wait指定构建上下文:
qshell sandbox template build --name my-app --dockerfile ./docker/Dockerfile --path ./src --waitDockerfile 模式会解析 FROM、RUN、COPY 等指令,并上传构建上下文中需要的文件。
带启动命令和就绪命令:
qshell sandbox template build \
--name my-service \
--dockerfile ./Dockerfile \
--start-cmd "python server.py" \
--ready-cmd "curl -f http://localhost:8000/health" \
--wait可以使用已有模板作为基础模板:
qshell sandbox template build --name my-derived-template --from-template <base-template-id> --wait这个方式适合在一个稳定基础环境上继续叠加依赖或文件。
重新构建已有模板时使用 --template-id:
qshell sandbox template build --template-id <template-id> --dockerfile ./Dockerfile --wait忽略缓存强制完整构建:
qshell sandbox template build --template-id <template-id> --dockerfile ./Dockerfile --no-cache --wait如果只是调整 Dockerfile 或依赖版本,建议使用 --no-cache 确认构建结果。
--wait 会等待构建完成并流式输出构建日志:
qshell sandbox template build --name my-app --dockerfile ./Dockerfile --wait不使用 --wait 时,构建命令会返回模板 ID 和构建 ID。之后可以查看状态:
qshell sandbox template builds <template-id> <build-id>列出模板:
qshell sandbox template listJSON 输出:
qshell sandbox template list --format json查看模板详情:
qshell sandbox template get <template-id>模板详情通常用于确认构建状态、资源配置、公开状态和历史构建记录。
发布模板:
qshell sandbox template publish <template-id> -y取消发布:
qshell sandbox template unpublish <template-id> -y也可以一次处理多个模板:
qshell sandbox template publish tmpl-aaa tmpl-bbb -y
qshell sandbox template unpublish tmpl-aaa tmpl-bbb -y删除单个模板:
qshell sandbox template delete <template-id> -y删除多个模板:
qshell sandbox template delete tmpl-aaa tmpl-bbb -y交互式选择删除:
qshell sandbox template delete --select| 参数 | 说明 |
|---|---|
--name | 创建新模板时使用的模板名称 |
--template-id | 重新构建已有模板时使用的模板 ID |
--from-image | 基础 Docker 镜像 |
--from-template | 基础沙箱模板 |
--dockerfile | Dockerfile 路径 |
--path | Dockerfile 构建上下文目录 |
--start-cmd | 沙箱启动命令 |
--ready-cmd | 就绪检查命令 |
--cpu | CPU 核数 |
--memory | 内存大小,单位 MiB |
--wait | 等待构建完成并显示日志 |
--no-cache | 忽略缓存,强制完整构建 |
--wait,便于直接查看失败原因。template-id 和 build-id,便于后续查询构建状态。这篇文档有帮助吗?
正在加载反馈服务…