dokploy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDokploy Infrastructure Management
Dokploy基础设施管理
Dokploy is a self-hosted PaaS. All management happens through its REST API using curl. No CLI tools or bash scripts — construct curl commands directly.
Dokploy是一款自托管PaaS,所有管理操作都通过curl调用其REST API完成,无需CLI工具或bash脚本,直接构造curl命令即可。
Authentication & Request Pattern
认证与请求规则
Environment variables (must be set):
- — base URL of the Dokploy instance (e.g.,
DOKPLOY_API_URL)https://dokploy.example.com - — API token generated from Dokploy UI: Settings → Profile → API/CLI Section
DOKPLOY_API_KEY
All endpoints follow the pattern:
$DOKPLOY_API_URL/api/{router}.{procedure}环境变量(必须提前配置):
- — Dokploy实例的基础地址(例如:
DOKPLOY_API_URL)https://dokploy.example.com - — 在Dokploy UI中生成的API令牌:设置 → 个人资料 → API/CLI板块
DOKPLOY_API_KEY
所有接口的地址规则为:
$DOKPLOY_API_URL/api/{router}.{procedure}GET request (reads)
GET请求(查询操作)
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/{endpoint}?{param}={value}"Parameters are flat query params. Do NOT use tRPC encoding — it doesn't work on the OpenAPI surface.
?input=bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/{endpoint}?{param}={value}"参数为扁平的查询参数,不要使用tRPC的编码格式,OpenAPI层面不支持该格式。
?input=POST request (all mutations)
POST请求(所有变更操作)
bash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/{endpoint}" \
-d '{"param": "value"}'Every mutation (create, update, remove, deploy, start, stop, reload) uses POST. Never use PUT, PATCH, or DELETE.
Always pipe output through for readability:
jq| jq .bash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/{endpoint}" \
-d '{"param": "value"}'所有变更操作(创建、更新、删除、部署、启动、停止、重载)都使用POST请求,不要使用PUT、PATCH或DELETE方法。
建议始终将输出通过处理提升可读性:
jq| jq .Response Formats
响应格式
Not all endpoints return JSON objects. Be aware of these patterns:
- ,
application.update, and other mutation endpoints may return a bareapplication.saveEnvironmentinstead of the updated object. Do not pipe these throughtruewith object filters — usejqor skipjq .entirely.jq - returns empty output on success.
application.deploy - GET endpoints (,
*.one) return full JSON objects.*.all - When in doubt, don't assume the response shape — capture raw output first.
并非所有接口都返回JSON对象,请注意以下规则:
- 、**
application.update**以及其他变更类接口可能直接返回布尔值application.saveEnvironment,而非更新后的对象。不要对这类响应使用带对象筛选规则的true命令,可使用jq或者直接跳过jq .处理。jq - 调用成功时返回空内容。
application.deploy - GET接口(、
*.one)返回完整的JSON对象。*.all - 存疑时不要假设响应结构,优先先获取原始输出。
Critical: The Resource Hierarchy
重点:资源层级结构
Project
└── Environment (default: "production")
├── Applications
├── Databases (postgres, mysql, mariadb, mongo, redis)
└── Compose services- Every project has at least one environment. The default is named "production" with .
isDefault: true - Creating any resource requires , NOT
environmentId.projectId - To get : fetch the project with
environmentId, then readproject.one(or find the environment by name)..environments[0].environmentId
This is the most common source of errors. Always fetch the environment first.
项目
└── 环境(默认:"production")
├── 应用
├── 数据库(postgres, mysql, mariadb, mongo, redis)
└── Compose服务- 每个项目至少包含一个环境,默认环境名为"production",对应。
isDefault: true - 创建任意资源都需要传入,而非
environmentId。projectId - 获取的方法:调用
environmentId查询项目信息,然后读取project.one(或按环境名称查找对应ID)。.environments[0].environmentId
这是最常见的错误来源,务必优先查询获取环境ID。
Quick Reference
快速参考
Projects & Environments
项目与环境
| Task | Endpoint | Method | Key Params |
|---|---|---|---|
| List all projects | | GET | — |
| Get project details | | GET | |
| Create project | | POST | |
| Update project | | POST | |
| Delete project | | POST | |
| 任务 | 接口 | 请求方法 | 核心参数 |
|---|---|---|---|
| 查询所有项目 | | GET | — |
| 获取项目详情 | | GET | |
| 创建项目 | | POST | |
| 更新项目 | | POST | |
| 删除项目 | | POST | |
Applications
应用
| Task | Endpoint | Method | Key Params |
|---|---|---|---|
| Get app details | | GET | |
| Create app | | POST | |
| Update app | | POST | |
| Delete app | | POST | |
| Deploy app | | POST | |
| Start app | | POST | |
| Stop app | | POST | |
| Redeploy app | | POST | |
| Save env vars | | POST | |
| Set build type | | POST | |
| 任务 | 接口 | 请求方法 | 核心参数 |
|---|---|---|---|
| 获取应用详情 | | GET | |
| 创建应用 | | POST | |
| 更新应用 | | POST | |
| 删除应用 | | POST | |
| 部署应用 | | POST | |
| 启动应用 | | POST | |
| 停止应用 | | POST | |
| 重新部署应用 | | POST | |
| 保存环境变量 | | POST | |
| 设置构建类型 | | POST | |
Databases
数据库
All database types share the same operation pattern. Replace with: , , , , .
{type}postgresmysqlmariadbmongoredis| Task | Endpoint | Method | Key Params |
|---|---|---|---|
| Get DB details | | GET | |
| Create DB | | POST | |
| Delete DB | | POST | |
| Deploy DB | | POST | |
| Start DB | | POST | |
| Stop DB | | POST | |
Note: Each type uses its own ID field name: , , , , .
postgresIdmysqlIdmariadbIdmongoIdredisId所有数据库类型的操作规则一致,将替换为对应类型:、、、、。
{type}postgresmysqlmariadbmongoredis| 任务 | 接口 | 请求方法 | 核心参数 |
|---|---|---|---|
| 获取数据库详情 | | GET | |
| 创建数据库 | | POST | |
| 删除数据库 | | POST | |
| 部署数据库 | | POST | |
| 启动数据库 | | POST | |
| 停止数据库 | | POST | |
注意:每种数据库类型使用独立的ID字段名:、、、、。
postgresIdmysqlIdmariadbIdmongoIdredisIdDomains
域名
| Task | Endpoint | Method | Key Params |
|---|---|---|---|
| Get domain | | GET | |
| Domains for app | | GET | |
| Create domain | | POST | |
| Update domain | | POST | |
| Delete domain | | POST | |
| 任务 | 接口 | 请求方法 | 核心参数 |
|---|---|---|---|
| 获取域名详情 | | GET | |
| 查询应用绑定的域名 | | GET | |
| 创建域名 | | POST | |
| 更新域名 | | POST | |
| 删除域名 | | POST | |
Compose
Compose
| Task | Endpoint | Method | Key Params |
|---|---|---|---|
| Get compose | | GET | |
| Create compose | | POST | |
| Update compose | | POST | |
| Delete compose | | POST | |
| Deploy compose | | POST | |
| Start compose | | POST | |
| Stop compose | | POST | |
| List services | | GET | |
| 任务 | 接口 | 请求方法 | 核心参数 |
|---|---|---|---|
| 获取Compose详情 | | GET | |
| 创建Compose | | POST | |
| 更新Compose | | POST | |
| 删除Compose | | POST | |
| 部署Compose | | POST | |
| 启动Compose | | POST | |
| 停止Compose | | POST | |
| 列出服务 | | GET | |
Deployments
部署记录
| Task | Endpoint | Method | Key Params |
|---|---|---|---|
| List deployments | | GET | |
| By type | | GET | |
typeapplicationcomposeserverschedulepreviewDeploymentbackupvolumeBackup| 任务 | 接口 | 请求方法 | 核心参数 |
|---|---|---|---|
| 列出部署记录 | | GET | |
| 按类型查询部署记录 | | GET | |
typeapplicationcomposeserverschedulepreviewDeploymentbackupvolumeBackupServers
服务器
| Task | Endpoint | Method | Key Params |
|---|---|---|---|
| List servers | | GET | — |
| Get server | | GET | |
| Create server | | POST | |
| Delete server | | POST | |
| 任务 | 接口 | 请求方法 | 核心参数 |
|---|---|---|---|
| 列出服务器 | | GET | — |
| 获取服务器详情 | | GET | |
| 创建服务器 | | POST | |
| 删除服务器 | | POST | |
Common Workflows
常见工作流
List all projects with their resources
列出所有项目及其关联资源
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/project.all" | jq .The response includes nested environments with all applications, databases, and compose services summarized.
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/project.all" | jq .响应包含嵌套的环境信息,以及所有应用、数据库、Compose服务的汇总信息。
Deploy an existing application
部署已有的应用
bash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/application.deploy" \
-d '{"applicationId": "THE_APP_ID"}' | jq .bash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/application.deploy" \
-d '{"applicationId": "THE_APP_ID"}' | jq .Create a new app in an existing project
在现有项目中创建新应用
Step 1 — Get the project's environmentId:
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/project.one?projectId=PROJECT_ID" \
| jq '.environments[] | select(.isDefault) | .environmentId'Step 2 — Create the application:
bash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/application.create" \
-d '{"name": "my-app", "environmentId": "ENV_ID"}' | jq .步骤1 — 获取项目的environmentId:
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/project.one?projectId=PROJECT_ID" \
| jq '.environments[] | select(.isDefault) | .environmentId'步骤2 — 创建应用:
bash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/application.create" \
-d '{"name": "my-app", "environmentId": "ENV_ID"}' | jq .Create a full project from scratch
从零创建完整项目
Step 1 — Create the project:
bash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/project.create" \
-d '{"name": "My Project", "description": "Project description"}' | jq .Step 2 — Get the new project's environmentId from the response, or fetch it:
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/project.all" \
| jq '.[] | select(.name == "My Project") | .environments[0].environmentId'Step 3 — Create resources using that environmentId (apps, databases, compose).
步骤1 — 创建项目:
bash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/project.create" \
-d '{"name": "My Project", "description": "Project description"}' | jq .步骤2 — 从响应中获取新项目的environmentId,或通过查询获取:
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/project.all" \
| jq '.[] | select(.name == "My Project") | .environments[0].environmentId'步骤3 — 使用该environmentId创建相关资源(应用、数据库、Compose)。
Check deployment status
查看部署状态
For applications:
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/deployment.all?applicationId=APP_ID" | jq '.[0]'For compose services:
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/deployment.allByType?id=COMPOSE_ID&type=compose" | jq '.[0]'应用部署状态:
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/deployment.all?applicationId=APP_ID" | jq '.[0]'Compose服务部署状态:
bash
curl -s -H "x-api-key: $DOKPLOY_API_KEY" \
"$DOKPLOY_API_URL/api/deployment.allByType?id=COMPOSE_ID&type=compose" | jq '.[0]'Set environment variables on an app
为应用设置环境变量
Env vars are set as a single newline-separated string block, not key-value pairs.
Required fields: , , and are mandatory (use empty strings and as defaults):
buildArgsbuildSecretscreateEnvFilefalsebash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/application.saveEnvironment" \
-d '{
"applicationId": "APP_ID",
"env": "DATABASE_URL=postgres://...\nREDIS_URL=redis://...\nNODE_ENV=production",
"buildArgs": "",
"buildSecrets": "",
"createEnvFile": false
}'环境变量以换行分隔的字符串块形式传入,而非键值对格式。
必填字段:、和为必填项(默认可传入空字符串和):
buildArgsbuildSecretscreateEnvFilefalsebash
curl -s -X POST \
-H "x-api-key: $DOKPLOY_API_KEY" \
-H "Content-Type: application/json" \
"$DOKPLOY_API_URL/api/application.saveEnvironment" \
-d '{
"applicationId": "APP_ID",
"env": "DATABASE_URL=postgres://...\nREDIS_URL=redis://...\nNODE_ENV=production",
"buildArgs": "",
"buildSecrets": "",
"createEnvFile": false
}'Important Notes
重要注意事项
- returns a comprehensive overview — use it to discover IDs before drilling down.
project.all - Deployment is asynchronous. After triggering deploy, poll or
deployment.allto check status.deployment.allByType - Destructive operations (,
remove) cannot be undone. Always confirm with the user first.delete - The Swagger UI is available at for interactive API exploration (admin only).
$DOKPLOY_API_URL/swagger
- 返回全面的概览信息,在查询具体资源前可先调用该接口获取对应ID。
project.all - 部署为异步操作,触发部署后,可轮询或
deployment.all接口查看状态。deployment.allByType - 破坏性操作(、
remove)无法撤销,执行前务必先和用户确认。delete - Swagger UI地址为,可用于交互式接口调试(仅管理员可访问)。
$DOKPLOY_API_URL/swagger
Reference Files
参考文件
For full endpoint details with all parameters:
| Need details about... | Read |
|---|---|
| Projects & environments | |
| Applications (CRUD, deploy, build types, git providers) | |
| Databases (PostgreSQL, MySQL, MariaDB, MongoDB, Redis) | |
| Domains (create, update, certificates) | |
| Docker Compose services | |
| Deployment history & logs | |
| Server management | |
如需查看所有参数的完整接口说明:
| 需要了解的内容 | 参考文档 |
|---|---|
| 项目与环境 | |
| 应用(CRUD、部署、构建类型、Git提供商) | |
| 数据库(PostgreSQL、MySQL、MariaDB、MongoDB、Redis) | |
| 域名(创建、更新、证书) | |
| Docker Compose服务 | |
| 部署历史与日志 | |
| 服务器管理 | |