mcpField
C
coolify-operator

coolify-operator

github.com/fabricioctelles云与 DevOps123100 次安装2 天前更新
代码仓库

关于 coolify-operator

coolify-operator 是通过官方 CLI 或 REST API 操作 Coolify 实例的技能,面向负责部署和运维的人员。它涵盖应用、服务、数据库和服务器管理,也包括数据库导入及外部密钥管理器操作。

主要功能

  1. 01管理应用、服务、数据库和服务器
  2. 02部署、重启和停止资源
  3. 03查看日志与部署状态
  4. 04配置备份并恢复数据库
  5. 05通过上下文切换 Coolify 实例

适用场景

  1. 01从代码仓库或 Docker 镜像部署应用
  2. 02运维时查看日志和部署状态
  3. 03从上传文件、S3 或服务器路径恢复数据库

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/fabricioctelles/skills --skill coolify-operator

安装后在 Claude Code 中输入/coolify-operator确认已加载。

附带文件.env.exampleevals/evals.json

详细介绍

Coolify 运维

通过 官方 CLI 或 REST API 操作 Coolify 实例的技能。Coolify 是一个可自托管的开源平台,可替代 Heroku/Vercel/Netlify,用于部署应用程序、数据库和服务。

固定上游版本: coolify-cli v1.10.0(e1d60947fc66c194d256b1049fd69c1ddf819760)——Coolify v4 功能范围。优先使用该标签下 llms.txt / llms-full.txt 中的命令形式。

已测试的 Coolify 版本: v4.4.6(2026 年 10 月)

CLI v1.10.0 重点
  • 新增: coolify database import start|upload|status 和 coolify service database import ...——从本地文件、之前上传的文件、S3 或服务器路径恢复备份
  • 新增: coolify audit list——团队审计日志(管理员/所有者)
  • 新增: coolify integration-token create + coolify app secret-manager set——Doppler / Infisical / Vault 密钥管理器
  • 新增: coolify app previews logs、coolify teams update --build-server-fallback、coolify project environments get
  • 新增: sqlite 数据库类型(--sqlite-databases)
  • coolify service application logs 支持 -n, --lines
CLI v1.9.0 重点
  • 新增: coolify app previews list|get|create|update(预览部署 API,Coolify v4.4.0+)
  • 新增: coolify server registry list|login|check|logout——服务器上的 Docker 镜像仓库登录信息
  • 新增: coolify server remove --force / --delete-from-provider
  • 新增: server add / server update 支持 --server-role deployment|build|both(已弃用 --is-build-server)
  • 变更: coolify server get <uuid> --resources 现在会调用 GET /servers/{uuid}/resources,并打印扁平列表(uuid、name、type、status),而非服务器详情
  • GitHub App 命令也接受数字形式的应用 ID
CLI v1.8.0 重点
  • 新增: 用于配置实例级 SMTP/Resend 设置的命令(coolify settings email get/update)
  • 安全性: 默认在 context list 输出中隐藏 API 令牌(使用 --show-sensitive 显示)
  • 修复: 现在会在应用环境变量创建/更新时正确发送 is_buildtime 字段
  • 不兼容变更: --retention-max-storage-locally 和 --retention-max-storage-s3 接受数值型 GB(例如 1、10.5),而非带单位后缀的字符串

何时使用此技能

  • 连接 Coolify 实例(通过 CLI 上下文或 API)
  • 创建、列出和管理应用程序、服务、数据库和服务器
  • 部署、重启或停止资源
  • 查看日志和部署状态
  • 管理环境变量、共享环境变量和存储
  • 配置数据库备份
  • 操作多个 Coolify 实例(上下文)
  • 集成 GitHub / GitLab Apps,以访问私有代码仓库
  • 配置通知和实例邮件(SMTP/Resend)
  • 管理 cloud-init 脚本并配置服务器(Hetzner、DigitalOcean、Vultr)
  • 恢复数据库备份(数据库导入)、查看团队审计日志、配置外部密钥管理器,以及管理服务器上的 Docker 镜像仓库登录信息

最近的变更(v4.4.x)

v4.4.0 — 重大功能版本

与 CLI/API 操作人员相关的亮点(参见 v4.4.0 版本发布说明):

  • SQLite 作为独立数据库类型(实验性)
  • 第三方密钥管理器(Doppler、Infisical、HashiCorp Vault)。{{vault.KEY}} 引用会在部署/数据库启动时解析,且不会存储在 Coolify 中
  • 团队审计日志(GET /audit-events,仅限管理员/所有者;事件在 90 天后清除)
  • 数据库导入 API,适用于独立数据库和服务数据库(上传、服务器路径或 S3)。上传/启动需要 write 权限;从服务器路径导入还需要 deploy 权限
  • 服务器角色(server_role:deployment / build / both);is_build_server 已弃用。团队设置决定构建是否回退到部署服务器
  • 按服务器配置 Docker 注册表登录信息(GET/POST /servers/{uuid}/registries、.../{registry}/check、DELETE .../{registry})。Coolify 会在服务器上运行 docker login,且不会存储令牌
  • 预览部署 API(GET /applications/{uuid}/previews[/{pr_id}],POST /applications/{uuid}/previews 需要 deploy 权限)
  • 从云服务提供商中删除服务器:DELETE /servers/{uuid}?delete_from_provider=true
  • 新挂载使用命名卷(现有绑定挂载保留其路径)

需留意的行为变更:

  • 单数据库 PostgreSQL 恢复默认不再删除现有对象——传入 replace_existing(--replace-existing)可恢复旧的 --clean 行为;除非指定 keep_owners(--keep-owners),否则会跳过所有者/权限
  • 环境变量名称必须匹配 [A-Za-z_][A-Za-z0-9_.]*(无效的构建时名称会导致构建停止)
  • 容器标签使用 UUID(coolify.applicationUuid、coolify.serviceUuid、coolify.databaseUuid);生成的容器名称会附加 ISO 8601 后缀
  • API 中的容器日志和计划任务输出端点需要 read:sensitive 权限
  • 多服务器应用:额外服务器必须使用相同的代理,并拉取主服务器的镜像;持久化卷和 Docker Compose 应用不能再与多服务器组合使用
v4.4.1 – v4.4.6
  • v4.4.1:卷备份通知和缺少卷备份的警报;Sentinel 1.0.2
  • v4.4.2:在部署服务器和构建服务器上运行 GitHub Actions Runner;按服务器控制流量分析 IP 存储
  • v4.4.3:修复静态站点 PR 预览;修复 API 更新中嵌套的 Base64 自定义标签
  • v4.4.4:新 DNS 记录支持可选的 Cloudflare 代理模式;IPv6 修复;修复 Infisical 引用展开
  • v4.4.5:移除阻止更新的 5 GB 可用空间要求
  • v4.4.6:固定 PHP 基础镜像,修复可自托管版本的启动失败

重大变更(v4.3.x)

v4.3.22 — 移除主机路径

已移除: 持久化卷的 host_path 配置。包含 host_path 的 API 请求现在会被拒绝。

# WRONG (no longer works)
coolify app storage create <uuid> \
  --type persistent \
  --mount-path /data \
  --host-path /opt/data  # ❌ Rejected

# CORRECT (use named volumes only)
coolify app storage create <uuid> \
  --type persistent \
  --mount-path /data \
  --name my-volume
v4.3.21 — 重启次数限制现改为选择启用

应用、预览部署和服务应用的重启次数限制现改为选择启用。此前默认限制为重启 10 次的现有资源已重置为无限制。

v4.3.19 — Sentinel 设为必需

**常规服务器现必须启用 Sentinel。**现有服务器已自动启用,且启用/停用设置已变为只读。这是即将推出的功能所必需的——Sentinel 将承担更多职责。

  • Sentinel 升级:0.0.22 → 1.0.1
  • 恢复对已启用服务器的每小时版本检查

CLI 安装

# Linux/macOS (recommended)
curl -fsSL https://raw.githubusercontent.com/coollabsio/coolify-cli/main/scripts/install.sh | bash

# Homebrew (macOS/Linux)
brew install coollabsio/coolify-cli/coolify-cli

# Windows (PowerShell)
irm https://raw.githubusercontent.com/coollabsio/coolify-cli/main/scripts/install.ps1 | iex

# Go install
go install github.com/coollabsio/coolify-cli/coolify@latest

在 Windows 上,可在运行 irm ... | iex 前使用 $env:COOLIFY_VERSION='v1.10.0' 固定版本。用户本地安装:$env:COOLIFY_USER_INSTALL=1。

基本概念

身份验证

CLI:

  • 上下文中存储 HOST + TOKEN
  • HOST 不包含 /api/v1(CLI 会自动添加)
  • 在此处获取令牌:Coolify 仪表板 → 安全 → API 令牌

REST API:

  • 基础端点:https://YOUR-HOST/api/v1(始终包含 /api/v1)
  • 请求头:Authorization: Bearer YOUR_TOKEN
在令牌中包含管道符的配置

Coolify 令牌通常包含 |(例如 3|abc123...)。切勿使用 source .env。

# Safe .env reading
COOLIFY_KEY=$(sed -n 's/^COOLIFY_KEY=//p' .env)
COOLIFY=$(sed -n 's/^COOLIFY=//p' .env)
全局标志

所有命令都支持这些标志(与 coolify-cli v1.10.0 一致):

--context <name>              # Use specific context instead of default
--token <token>               # Override authentication token
--format table|json|pretty    # Output format (default: table)
-s, --show-sensitive          # Reveal sensitive fields (tokens, IPs, emails)
--debug                       # Enable debug mode

配置文件中存储的是明文令牌,切勿提交 ~/.config/coolify/config.json(Windows:%APPDATA%\coolify\config.json)。


CLI 操作

实用工具命令
# Update CLI to latest version
coolify update

# Show current CLI version
coolify version

# Show configuration file location
coolify config

# Generate shell completion
coolify completion bash   # or: zsh, fish, powershell
上下文管理

在 coolify context list / get 中,令牌、IP 和电子邮件默认隐藏(v1.8.0+)。传入 -s / --show-sensitive 可显示这些信息。配置文件仍会存储明文令牌,请勿提交该文件。

# List all configured contexts (redacted by default — v1.8.0+ security fix)
coolify context list
coolify context list --show-sensitive  # reveal tokens

# Add new context
coolify context add <context_name> <url> <token>
coolify context add -d my-coolify http://192.168.1.100:8000 "$TOKEN"  # -d sets as default
coolify context add -f prod https://prod.coolify.io "$TOKEN"          # -f force overwrite

# For Coolify Cloud
coolify context set-token cloud <token>

# Get context details
coolify context get <context_name>

# Delete context
coolify context delete <context_name>

# Update context token
coolify context set-token <context_name> <new_token>

# Set default context
coolify context set-default <context_name>
coolify context use <context_name>  # alias

# Update context properties
coolify context update <context_name> --name <new_name>
coolify context update <context_name> --url <new_url>
coolify context update <context_name> --token <new_token>

# Verify connection and authentication
coolify context verify

# Get Coolify API version
coolify context version
项目

主要形式为单数 coolify project(别名 projects 仍可使用)。

# List all projects
coolify project list

# Get project details / environments
coolify project get <uuid>
coolify project environments list <project_uuid>

# Create new project
coolify project create --name "My Project" --description "Description"

# Get one environment and its applications, databases and services (v1.10.0+, alias: env)
coolify project environments get <project_uuid> <environment_name_or_uuid>
资源
# List all resources (apps, databases, services)
coolify resource list
命令别名(v1.10)

优先使用 llms.txt 中的主要形式。以下别名仍可使用:

  • coolify app | apps | application | applications
  • coolify service | services | svc
  • coolify database | databases | db | dbs
  • coolify project | projects
  • coolify resource | resources
  • coolify server | servers
  • coolify teams | team
  • coolify github | gh(以及 GitLab:gitlab | gl | gitlab-app)
  • coolify audit | audit-events | audit-log
  • coolify integration-token | integration-tokens
  • coolify server registry | registries;coolify database import | imports

应用

列出和查看
# List all applications
coolify app list

# Get application details
coolify app get <uuid>
创建应用
从公共 Git 仓库创建
coolify app create public \
  --server-uuid <uuid> \
  --project-uuid <uuid> \
  --environment-name production \
  --git-repository "https://github.com/user/repo" \
  --git-branch main \
  --build-pack nixpacks \
  --ports-exposes 3000 \
  --domains "app.example.com" \
  --instant-deploy

# Build packs: nixpacks, static, dockerfile, dockercompose
# Additional flags:
#   --name, --description, --base-directory, --publish-directory
#   --build-command, --start-command, --install-command
#   --health-check-enabled, --health-check-path
#   --limits-memory, --limits-cpus, --ports-mappings
#   --git-commit-sha, --destination-uuid, --dockerfile-target-build
#   --tag, --tags (for tagging)
#   --compose-domain <service>=<url> (for Docker Compose)
从私有 GitHub 仓库创建(通过 GitHub App)
coolify app create github \
  --server-uuid <uuid> \
  --project-uuid <uuid> \
  --environment-name production \
  --github-app-uuid <github-app-uuid> \
  --git-repository "owner/repo" \
  --git-branch main \
  --build-pack nixpacks \
  --ports-exposes 3000
从私有仓库创建(通过部署密钥)
coolify app create deploy-key \
  --server-uuid <uuid> \
  --project-uuid <uuid> \
  --environment-name production \
  --private-key-uuid <key-uuid> \
  --git-repository "[email protected]:owner/repo.git" \
  --git-branch main \
  --build-pack nixpacks \
  --ports-exposes 3000
从 Dockerfile 创建
coolify app create dockerfile \
  --server-uuid <uuid> \
  --project-uuid <uuid> \
  --environment-name production \
  --dockerfile "FROM node:20\nCOPY . .\nRUN npm install\nCMD [\"npm\", \"start\"]"
从 Docker 镜像创建
coolify app create dockerimage \
  --server-uuid <uuid> \
  --project-uuid <uuid> \
  --environment-name production \
  --docker-registry-image-name nginx \
  --docker-registry-image-tag latest \
  --ports-exposes 80
更新应用
coolify app update <uuid> \
  --name "New Name" \
  --description "New description" \
  --git-branch develop \
  --git-repository "https://github.com/user/repo" \
  --domains "app.example.com,www.example.com" \
  --compose-domain web=https://web.example.com \
  --build-command "npm run build" \
  --start-command "npm start" \
  --install-command "npm install" \
  --base-directory "/app" \
  --publish-directory "/app/dist" \
  --dockerfile "FROM node:20..." \
  --docker-image nginx \
  --docker-tag latest \
  --ports-exposes "3000,8080" \
  --ports-mappings "3000:3000" \
  --health-check-enabled \
  --health-check-path "/health"
按域名覆盖内部端口(v4.3.15+)

现在,应用、Docker Compose 服务和预览部署都支持按域名覆盖内部端口。公共 URL 不包含端口,而内部路由则使用指定的端口。

# Via API: PATCH /api/v1/applications/{uuid}
# Use domains array with port_override field
curl -sS -X PATCH -H "Authorization: Bearer $COOLIFY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "domains": [
      {"fqdn": "app.example.com", "port_override": 3000},
      {"fqdn": "api.example.com", "port_override": 8080}
    ]
  }' \
  "$COOLIFY/applications/{uuid}"

# Note: The UI shows effective ports and warns about unrecognized ports
# Works with both Traefik and Caddy proxies
生命周期管理
# Start application
coolify app start <uuid>

# Stop application
coolify app stop <uuid>

# Restart application
coolify app restart <uuid>

# Delete application
coolify app delete <uuid>
coolify app delete <uuid> -f  # skip confirmation

# Move to another environment
coolify app move <uuid> --environment-uuid <env-uuid>
应用日志
# Get logs
coolify app logs <uuid>

# Follow logs (like tail -f)
coolify app logs <uuid> -f

# Limit lines (or use 'all' / -1 for unlimited — v4.3.20+)
coolify app logs <uuid> -n 50
coolify app logs <uuid> -n all

# Show timestamps
coolify app logs <uuid> --show-timestamps

# Logs for specific Docker Compose service
coolify app logs <uuid> --service web
应用标签
# List tags
coolify app tag list <uuid>

# Add tag
coolify app tag add <uuid> <tag-name>

# Remove tag
coolify app tag remove <uuid> <tag-name>
应用环境变量
# List all env vars
coolify app env list <uuid>

# Get specific env var
coolify app env get <uuid> <env_uuid_or_key>

# Create env var
coolify app env create <uuid> \
  --key API_KEY \
  --value secret123 \
  --preview \
  --build-time \
  --runtime \
  --comment "API key for external service" \
  --is-literal \
  --is-multiline

# Update env var
coolify app env update <uuid> <env_uuid_or_key> \
  --value new-value \
  --key NEW_KEY  # optional, for renaming

# Delete env var
coolify app env delete <uuid> <env_uuid>
coolify app env delete <uuid> <env_uuid> --force

# Sync from .env file (updates existing, creates new, keeps others)
coolify app env sync <uuid> --file .env
coolify app env sync <uuid> --file .env.production --build-time --runtime --preview --is-literal
# short form also valid: -f .env
应用存储
# List storages
coolify app storage list <uuid>

# Create persistent volume (named volume only — host_path removed in v4.3.22)
coolify app storage create <uuid> \
  --type persistent \
  --mount-path /data \
  --name my-volume

# Create file mount
coolify app storage create <uuid> \
  --type file \
  --mount-path /app/config.json \
  --content '{"key": "value"}'

# Create directory mount
coolify app storage create <uuid> \
  --type file \
  --mount-path /app/config \
  --is-directory \
  --fs-path /opt/config

# Update storage
coolify app storage update <uuid> \
  --uuid <storage-uuid> \
  --type persistent \
  --is-preview-suffix-enabled

# Delete storage
coolify app storage delete <uuid> <storage-uuid>
应用部署
# List deployments
coolify app deployments list <uuid>

# Get deployment logs (latest)
coolify app deployments logs <uuid>

# Get specific deployment logs
coolify app deployments logs <uuid> <deployment-uuid>

# Follow deployment logs
coolify app deployments logs <uuid> -f

# Limit lines
coolify app deployments logs <uuid> -n 50

# Show debug logs
coolify app deployments logs <uuid> --debuglogs
应用预览

CLI v1.9.0 起支持完整的增删改查(日志功能自 v1.10.0 起支持)。列出、获取和创建需要 Coolify v4.4.0+(create 需要带有 deploy 权限的令牌)。

# List / get preview deployments
coolify app previews list <app_uuid>
coolify app previews get <app_uuid> <pr_id>

# Open (or redeploy) a preview and queue its deployment (aliases: open, deploy)
coolify app previews create <app_uuid> 42 --git-type github
coolify app previews create <app_uuid> 42 --git-type bitbucket --commit 1a2b3c4d
coolify app previews create <app_uuid> 42 --docker-tag pr-42     # Docker Image apps
coolify app previews create <app_uuid> 42 --git-type gitlab --no-deploy
# --git-type github|gitlab|gitea|bitbucket (not needed for GitHub App / GitLab App sources)
# --url <pr-url>, --force (rebuild without cache)

# Replace the domains of a preview (--domains and --compose-domain are mutually exclusive)
coolify app previews update <app_uuid> 42 --domains "pr-42.example.com"
coolify app previews update <app_uuid> 42 --compose-domain web=https://pr-42.example.com
coolify app previews update <app_uuid> 42 --domains "pr-42.example.com" --force-domain-override

# Runtime logs of a preview (v1.10.0+)
coolify app previews logs <app_uuid> 42
coolify app previews logs <app_uuid> 42 -n -1 --show-timestamps   # -1 = all lines
coolify app previews logs <app_uuid> 42 -f --service web

# Delete preview deployment
coolify app previews delete <app_uuid> <pr_id>
coolify app previews delete <app_uuid> <pr_id> --force

# API equivalent for logs (v4.3.23+; token needs read:sensitive since v4.4.0): lines (int or "all"), timestamps (bool)
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" \
  "$COOLIFY/applications/{uuid}/previews/{pr_id}/logs?lines=100&timestamps=true"
应用密钥管理器(v1.10.0+)

将应用指向外部密钥管理器(Doppler、Infisical、HashiCorp Vault)。先创建集成令牌(参见密钥管理器集成令牌),然后在环境变量值中使用 {{vault.KEY}} 引用密钥。密钥值会在部署时解析,且不会存储在 Coolify 中。

coolify app secret-manager set <app_uuid> --integration-token <token_uuid>
coolify app secret-manager set <app_uuid> --integration-token <token_uuid> \
  --settings '{"mount":"secret","path":"apps/web"}'

# --settings per provider (JSON object):
#   doppler    {"project":"...","config":"..."}   (required for service account tokens)
#   infisical  {"project_id":"...","environment":"...","secret_path":"/"}
#   vault      {"mount":"...","path":"..."}

数据库

列出和查看
# List all databases
coolify database list

# Get database details
coolify database get <uuid>
创建数据库
# Supported types: postgresql, mysql, mariadb, mongodb, redis, keydb, clickhouse, dragonfly, sqlite (v1.10.0+)

coolify database create postgresql \
  --server-uuid <uuid> \
  --project-uuid <uuid> \
  --environment-name production \
  --name mydb \
  --description "Production database" \
  --image postgres:16 \
  --instant-deploy \
  --is-public \
  --public-port 5432 \
  --limits-memory 2g \
  --limits-cpus 2

# Database-specific flags available (postgres-user, mysql-root-password, etc.)
# Supports --tag and --tags for tagging

# SQLite (Coolify v4.4.0+, experimental) — no --is-public / --public-port
coolify database create sqlite \
  --server-uuid <uuid> \
  --project-uuid <uuid> \
  --environment-name production \
  --sqlite-databases app.db,cache.db
更新和删除
# Update database configuration
coolify database update <uuid> --name "New Name"
coolify database update <uuid> --sqlite-databases app.db,cache.db  # SQLite only

# Delete database
coolify database delete <uuid> \
  --delete-configurations \
  --delete-volumes \
  --docker-cleanup \
  --delete-connected-networks
生命周期管理
coolify database start <uuid>
coolify database stop <uuid>
coolify database restart <uuid>
coolify database logs <uuid>
coolify database move <uuid> --environment-uuid <env-uuid>
数据库标签
coolify database tag list <uuid>
coolify database tag add <uuid> <tag-name>
coolify database tag remove <uuid> <tag-name>
数据库环境变量
# Same structure as app env commands
coolify database env list <uuid>
coolify database env get <uuid> <env_uuid_or_key>
coolify database env create <uuid> --key DB_DEBUG --value true
coolify database env update <uuid> <env_uuid_or_key> --value new-value
coolify database env delete <uuid> <env_uuid> --force
coolify database env sync <uuid> --file .env
数据库存储
# Same structure as app storage commands
coolify database storage list <uuid>
coolify database storage create <uuid> --type persistent --mount-path /data
coolify database storage update <uuid> --uuid <storage-uuid> --type persistent
coolify database storage delete <uuid> <storage-uuid>
数据库备份

保留存储单位:--retention-max-storage-locally / --retention-max-storage-s3 的单位为 float64 GB(例如 1 或 10)。请勿传入 1GB / 10GB 之类的后缀。

v4.3.18+:仅使用 S3 的卷归档会直接流式传输到 S3(无需临时本地磁盘)。

v4.3.18+:可配置计划备份缺失 X 天后的告警(参见 --alert-after-missing-days)。

# List backup configurations
coolify database backup list <uuid>

# Create backup configuration
coolify database backup create <uuid> \
  --frequency "0 2 * * *" \
  --enabled \
  --save-s3 \
  --s3-storage-uuid <uuid> \
  --databases-to-backup "db1,db2" \
  --dump-all \
  --retention-amount-locally 10 \
  --retention-days-locally 7 \
  --retention-max-storage-locally 1 \
  --retention-amount-s3 30 \
  --retention-days-s3 30 \
  --retention-max-storage-s3 10 \
  --timeout 3600 \
  --disable-local-backup

# Update backup configuration
coolify database backup update <uuid> <backup-uuid> --frequency "0 3 * * *"

# Delete backup configuration
coolify database backup delete <uuid> <backup-uuid>

# Trigger immediate backup
coolify database backup trigger <uuid> <backup-uuid>

# List backup executions
coolify database backup executions <uuid> <backup-uuid>

# Delete backup execution
coolify database backup delete-execution <uuid> <backup-uuid> <execution-uuid>
数据库导入(恢复)— v1.10.0+

需要 Coolify v4.4.0+。start 必须且只能指定一个来源:--file、--upload-id、--s3-storage-uuid + --s3-path,或 --server-path。上传和启动需要带有 write 权限的令牌;--server-path 还需要 deploy 权限。本地文件最大为 10 GiB(按 10 MB 分块上传)。

# Upload a local dump and import it, waiting for the result (non-zero exit on failure)
coolify database import start <database_uuid> --file ./dump.sql.gz --wait

# Two-step: upload first (prints an upload ID), then import
coolify database import upload <database_uuid> ./dump.sql.gz
coolify database import start <database_uuid> --upload-id <upload_id>

# From S3 storage or from a file already on the database's server
coolify database import start <database_uuid> --s3-storage-uuid <s3-uuid> --s3-path /backups/db.dump
coolify database import start <database_uuid> --server-path /path/on/server/db.dump

# Check status (activity ID is printed by start); --wait to follow, --poll-interval (default 3s)
coolify database import status <database_uuid> <activity_id> --wait

# Restore options
#   --dump-all              backup contains all databases
#   --replace-existing      PostgreSQL: drop matching objects first (old --clean behavior; off by default since v4.4.0)
#   --keep-owners           PostgreSQL: restore owners and privileges
#   --restore-mysql-users   MySQL/MariaDB all-databases: also restore users/passwords/privileges
#   --sqlite-database app.db  SQLite: target database file

服务(一键部署)

列出和查看
# List all services
coolify service list

# Get service details
coolify service get <uuid>

# List available service types
coolify service create --list-types
创建服务
# Examples: wordpress-with-mysql, ghost, n8n, etc.
coolify service create wordpress-with-mysql \
  --server-uuid <uuid> \
  --project-uuid <uuid> \
  --environment-name production \
  --name "My WordPress" \
  --description "Company blog" \
  --docker-compose "custom compose content" \
  --destination-uuid <uuid> \
  --instant-deploy \
  --tag production \
  --tags "blog,cms"
生命周期管理
coolify service start <uuid>
coolify service stop <uuid>
coolify service restart <uuid>
coolify service delete <uuid>
coolify service move <uuid> --environment-uuid <env-uuid>

# Get logs (requires sub-service name)
coolify service logs <uuid> --sub-service-name wordpress
服务标签
coolify service tag list <uuid>
coolify service tag add <uuid> <tag-name>
coolify service tag remove <uuid> <tag-name>
服务应用(子资源)
# List applications in service
coolify service application list <service-uuid>

# Get application details
coolify service application get <service-uuid> <app-uuid>

# Update application
coolify service application update <service-uuid> <app-uuid>

# Get logs (-n/--lines, default 100 — v1.10.0+)
coolify service application logs <service-uuid> <app-uuid>
coolify service application logs <service-uuid> <app-uuid> -n 500

# Lifecycle
coolify service application start <service-uuid> <app-uuid>
coolify service application restart <service-uuid> <app-uuid>
coolify service application stop <service-uuid> <app-uuid>
服务数据库(子资源)
# List databases in service
coolify service database list <service-uuid>

# Get database details
coolify service database get <service-uuid> <db-uuid>

# Update database (image, log drain, public access)
coolify service database update <service-uuid> <db-uuid>

# Get logs
coolify service database logs <service-uuid> <db-uuid>

# Lifecycle
coolify service database start <service-uuid> <db-uuid>
coolify service database restart <service-uuid> <db-uuid>
coolify service database stop <service-uuid> <db-uuid>

# Import a backup into a service database (v1.10.0+, same source/option flags as `database import start`)
coolify service database import start <service-uuid> <db-uuid> \
  --s3-storage-uuid <s3-uuid> --s3-path /backups/db.dump
coolify service database import upload <service-uuid> <db-uuid> ./dump.sql.gz
coolify service database import status <service-uuid> <db-uuid> <activity_id> --wait
服务环境变量
# Same structure as app env (without --preview)
coolify service env list <uuid>
coolify service env get <uuid> <env_uuid_or_key>
coolify service env create <uuid> --key KEY --value value --build-time --runtime
coolify service env update <uuid> <env_uuid_or_key> --value new-value
coolify service env delete <uuid> <env_uuid> --force
coolify service env sync <uuid> --file .env --build-time --runtime
服务存储
coolify service storage list <uuid>

# Requires --resource-uuid (app or db that owns the storage)
coolify service storage create <uuid> \
  --resource-uuid <app-or-db-uuid> \
  --type persistent \
  --mount-path /data

coolify service storage update <uuid> --uuid <storage-uuid> --type persistent
coolify service storage delete <uuid> <storage-uuid>

部署

部署资源
# Deploy by UUID
coolify deploy uuid <uuid>
coolify deploy uuid <uuid> --force
coolify deploy uuid <uuid> --pull-request-id 123
coolify deploy uuid <uuid> --docker-tag 1.2.3  # requires Coolify 4.0.0-beta.471+

# Deploy by name (easier)
coolify deploy name my-application
coolify deploy name my-application --force

# Deploy multiple at once
coolify deploy batch api,worker,frontend
coolify deploy batch api,worker --force
监控部署
# List all deployments
coolify deploy list

# Get deployment details
coolify deploy get <deployment-uuid>

# Cancel deployment
coolify deploy cancel <deployment-uuid>
coolify deploy cancel <deployment-uuid> -f

服务器

列出和查看
# List all servers
coolify server list
coolify servers list  # alias

# Get server details
coolify server get <uuid>

# List resources deployed on the server (v1.9.0+ shape)
coolify server get <uuid> --resources
coolify server get <uuid> --resources --format json | jq -r '.[] | "\(.type)\t\(.name)\t\(.status)"'
# Since CLI v1.9.0 this calls GET /servers/{uuid}/resources and returns a flat JSON array of
# {id, uuid, name, type, status, created_at, updated_at} — it no longer prints the server
# details, and there is no top-level `resources` key (old: GET /servers/{uuid}?resources=true).

# Get server domains
coolify server domains <uuid>
添加和移除
# Add new server
coolify server add <name> <ip> <private_key_uuid>
coolify server add myserver 192.168.1.100 <key-uuid> -p 22 -u root --validate
coolify server add builder 192.168.1.101 <key-uuid> --server-role build   # v1.9.0+

# Update a server (only the given flags change)
coolify server update <uuid> --server-role deployment   # deployment|build|both
# 'deployment' requires another usable build server in the team.
# --is-build-server is deprecated (true → build, false → both) and cannot be combined with --server-role.
# Other flags: --name, --description, --ip, --port, --user, --private-key-uuid, --proxy-type, ...

# Remove server
coolify server remove <uuid>
coolify server remove <uuid> --force                          # also delete all resources on it (v1.9.0+)
coolify server remove <uuid> --force --delete-from-provider   # also delete the VM at Hetzner/Vultr/DigitalOcean — irreversible

# Validate server connection
coolify server validate <uuid>
服务器 Docker 注册表(v1.9.0+)

需要 Coolify v4.4.0+。Coolify 会在服务器上运行 docker login,且不会存储密码。没有密码标志——请使用 --password-stdin 传入密码,或在不回显的提示符中输入。

# List registry logins and which resources use them (token needs read:sensitive; -s shows usernames)
coolify server registry list <server_uuid>

# Log in on one or more servers
echo "$GHCR_TOKEN" | coolify server registry login <server_uuid> \
  --registry ghcr.io --username octocat --password-stdin
coolify server registry login <uuid_1> <uuid_2> --registry registry.example.com:5000 -u deploy

# Check that a saved login still works / log out
coolify server registry check <server_uuid> ghcr.io
coolify server registry logout <server_uuid> ghcr.io -f
服务器目标位置
# List destinations
coolify server destinations list <server-uuid>

# Create destination
coolify server destinations create <server-uuid>
云服务提供商
# List provider options and provision servers
coolify server hetzner
coolify server digitalocean
coolify server vultr

# Optional: pass --cloud-init '<yaml>' on create (see Cloud-init Scripts)

GitHub 应用

# List all GitHub Apps
coolify github list

# Get GitHub App details
coolify github get <app-uuid>

# Create GitHub App integration
coolify github create \
  --name "My GitHub App" \
  --api-url "https://api.github.com" \
  --html-url "https://github.com" \
  --app-id 123456 \
  --installation-id 789012 \
  --client-id "Iv1.abc123" \
  --client-secret "secret" \
  --private-key-uuid <key-uuid> \
  --organization "my-org" \
  --custom-user git \
  --custom-port 22 \
  --webhook-secret "webhook-secret" \
  --system-wide  # cloud only

# Update GitHub App
coolify github update <app-uuid>

# Delete GitHub App
coolify github delete <app-uuid>
coolify github delete <app-uuid> -f

# List accessible repositories
coolify github repos <app-uuid>

# List branches for a repository
coolify github branches <app-uuid> owner/repo

GitLab 应用

GitLab 应用集成(别名:gl、gitlab-app、gitlab-apps)。

# List / get
coolify gitlab list
coolify gitlab get <app_id_or_uuid>

# Create
coolify gitlab create \
  --name "My GitLab App" \
  --html-url "https://gitlab.com" \
  --client-id "<oauth-app-id>" \
  --client-secret "<oauth-secret>" \
  --redirect-uri "https://<coolify-host>/webhooks/source/gitlab/events/app" \
  --api-url "https://gitlab.com/api/v4" \
  --custom-user git \
  --custom-port 22 \
  --group-name "my-group" \
  --webhook-token "<optional-secret>"

# Update / delete (must not be used by any applications)
coolify gitlab update <app_id_or_uuid> --name "Renamed"
coolify gitlab delete <app_id_or_uuid>
coolify gitlab delete <app_id_or_uuid> -f
从 GitLab 应用创建应用程序

在 Coolify 4.3.23 中已确认,在 4.4.6 中仍然如此(没有 private-gitlab-app 路由)。API 会创建 OAuth 源。与该源关联的应用程序需在 UI 的“Git Repository (with GitLab App)”下创建。

POST /api/v1/gitlab-apps 只会存储源(name、html_url、凭据)。不存在 POST /api/v1/applications/private-gitlab-app——此路由会返回 404。应用程序仅有以下创建端点:

  • POST /api/v1/applications/public
  • POST /api/v1/applications/private-github-app(github_app_uuid)
  • POST /api/v1/applications/private-deploy-key(private_key_uuid)
  • POST /api/v1/applications/dockerfile
  • POST /api/v1/applications/dockerimage

UI 创建应用程序后,source_type 会变为 App\Models\GitlabApp,而 source_id 则是源的数字 ID。之后即可通过 API 正常编辑:PATCH /api/v1/applications/{uuid}、环境变量和存储。

当 build_pack 为 dockercompose 时,domains 会被拒绝,并提示“The domains field cannot be used for dockercompose applications”。请先更改构建包(build_pack: dockerfile、dockerfile_location、ports_exposes),然后再发送 domains。请在首次部署生成 custom_labels 之前定义 ports_exposes;之后更改端口不会重新生成 Traefik 标签。

Coolify 不会在 GitLab 项目上创建 webhook。要通过推送触发部署,必须在 POST /webhooks/source/gitlab/events 上配置项目 hook,并使用源的 webhook 令牌。UI 提示由 Git App 管理此项,但代码中没有调用 POST /api/v4/projects/:id/hooks(问题 coollabsio/coolify#11602)。


通知

渠道:email、discord、slack、telegram、pushover、webhook。通过 get/update + --json 配置。

coolify notification get webhook
coolify notification update webhook --json '{"webhook_enabled":true}'

coolify notification get discord
coolify notification update slack --json '{"slack_enabled":true}'

共享环境变量

范围为环境、项目、服务器或团队的共享环境变量(别名:shared-envs / sharedenv)。

# Environment scope
coolify shared-env environment list <project_uuid> <environment>
coolify shared-env environment create <project_uuid> production \
  --key SHARED_API_URL --value "https://api.example.com"
coolify shared-env environment update <project_uuid> production <id> --value "https://api.new.example.com"
coolify shared-env environment delete <project_uuid> production <id>

# Project scope
coolify shared-env project list <project_uuid>
coolify shared-env project create <project_uuid> --key PROJECT_FLAG --value "1"
coolify shared-env project update <project_uuid> <id> --value "0"
coolify shared-env project delete <project_uuid> <id>

# Server scope
coolify shared-env server list <server_uuid>
coolify shared-env server create <server_uuid> --key NODE_ROLE --value "worker"
coolify shared-env server update <server_uuid> <id> --value "api"
coolify shared-env server delete <server_uuid> <id>

# Team scope
coolify shared-env team list
coolify shared-env team create --key ORG_NAME --value "acme"
coolify shared-env team update <id> --value "acme-corp"
coolify shared-env team delete <id>

创建/更新时可选的标志:--comment、--literal、--multiline、--shown-once。


Cloud-init 脚本

对可重复使用的 cloud-init 脚本进行 CRUD。通过 Hetzner / DigitalOcean / Vultr 创建服务器时可使用 --cloud-init(内联 YAML)。

coolify cloud-init list
coolify cloud-init get <uuid>

coolify cloud-init create --name bootstrap --script-file ./cloud-init.yaml
# or: --script "#!/bin/bash\necho hi"

coolify cloud-init update <uuid> --name bootstrap-v2 --script-file ./cloud-init-v2.yaml
coolify cloud-init delete <uuid>

# Attach when provisioning (example)
coolify server hetzner create \
  --cloud-token <cloud-token-uuid> \
  --location <location> \
  --server-type <type> \
  --image <id> \
  --cloud-init "$(cat ./cloud-init.yaml)"

别名:cloudinit、cloud-init-script。


设置(电子邮件)

实例范围的 SMTP / Resend 设置。需要具有 write:sensitive 权限的 root 团队管理员/所有者令牌。

coolify settings email get

# Update fields via JSON
coolify settings email update --json '{"smtp_ehlo_domain":"coolify.example.com"}'

# Reset EHLO domain to system default
coolify settings email update --json '{"smtp_ehlo_domain":null}'

密钥管理器集成令牌

v1.10.0+ / Coolify v4.4.0+。提供商:doppler、infisical、vault。没有用于提供商令牌的标志,且绝不会打印该令牌:请使用 --provider-token-stdin 传入、设置 COOLIFY_INTEGRATION_TOKEN,或在不回显的提示符中输入。

echo "$DOPPLER_TOKEN" | coolify integration-token create \
  --provider doppler --name prod --provider-token-stdin

# Infisical / Vault need --metadata
#   infisical {"base_url":"...","client_id":"..."}
#   vault     {"base_url":"...","namespace":"..."}   (namespace optional)
echo "$VAULT_TOKEN" | coolify integration-token create \
  --provider vault --name vault --provider-token-stdin \
  --metadata '{"base_url":"https://vault.example.com"}'

然后使用 coolify app secret-manager set 将其关联到应用(参见“应用程序”)。


审计日志

v1.10.0+ / Coolify v4.4.0+。只有团队管理员和所有者可以读取审计事件(按最新时间优先)。

coolify audit list
coolify audit list --source api --per-page 50
coolify audit list --action deleted --search my-app --page 2
coolify audit list --format json

# --per-page 1-100 (default 25), --page (default 1), --search <text>
# --action created|updated|deleted|... (all = every action)
# --source all|ui|api|mcp|webhook|system|scheduler
# Actor e-mail, token, metadata, changes, IP and user agent are returned only for
# tokens with read:sensitive — use --format json to see them.

标签

# List all tags for current team
coolify tag list

目标位置

# List Docker network destinations
coolify destination list
coolify destination list --server <server-uuid>

# Get destination
coolify destination get <uuid>

# Create destination
coolify destination create --server <uuid> --network my-network --type standalone
# Types: standalone, swarm

# Delete unused destination
coolify destination delete <uuid>

云服务提供商令牌

# Manage Hetzner, DigitalOcean, Vultr API tokens
coolify cloud-token list
coolify cloud-token get <uuid>
coolify cloud-token create
coolify cloud-token update <uuid>
coolify cloud-token delete <uuid>
coolify cloud-token validate <uuid>

# Note: Token values redacted by default. Use --show-sensitive with sensitive-data permission

团队

# List all teams
coolify team list

# Get team details
coolify team get <team_id>

# Get current team
coolify team current

# Allow/deny build fallback to the deployment server when no build server is usable (v1.10.0+)
coolify teams update --build-server-fallback
coolify teams update --build-server-fallback=false

# List team members
coolify team members list
coolify team members list <team_id>

私钥

# Commands: private-key, private-keys, key, keys (aliases)

# List all private keys
coolify private-key list

# Add new private key (content or file path)
coolify private-key add <key_name> <private_key_or_file>
coolify private-key add mykey ~/.ssh/id_rsa
coolify private-key add mykey "-----BEGIN OPENSSH PRIVATE KEY-----..."

# Remove private key
coolify private-key remove <uuid>

REST API 操作

CLI 不可用时,可直接访问 API:

身份验证
COOLIFY_KEY=$(sed -n 's/^COOLIFY_KEY=//p' .env)
COOLIFY=$(sed -n 's/^COOLIFY=//p' .env)  # includes /api/v1

# Test connection
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/version"
应用程序(API)
# List
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/applications"

# Get details
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/applications/{uuid}"

# Start (POST required since v4.2.0)
curl -sS -X POST -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/applications/{uuid}/start"
curl -sS -X POST -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/applications/{uuid}/start?force=true"

# Stop
curl -sS -X POST -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/applications/{uuid}/stop"

# Restart
curl -sS -X POST -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/applications/{uuid}/restart"
数据库(API)
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/databases"
curl -sS -X POST -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/databases/{uuid}/start"
curl -sS -X POST -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/databases/{uuid}/stop"
curl -sS -X POST -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/databases/{uuid}/restart"
服务(API)
curl -sS -X POST -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/services/{uuid}/restart"
curl -sS -X POST -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/services/{uuid}/restart?latest=true"
部署(API)
# List all ongoing
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/deployments"

# List for application
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/deployments/applications/{uuid}?skip=0&take=10"
服务端(API)
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/servers"
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/servers/{uuid}"

# Resources deployed on a server (flat array)
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/servers/{uuid}/resources"

# Registry logins (v4.4.0+)
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/servers/{uuid}/registries"
预览、导入、审计(API,v4.4.0+)
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/applications/{uuid}/previews"
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/applications/{uuid}/previews/{pr_id}"
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/databases/{uuid}/imports/{activity_id}"
curl -sS -H "Authorization: Bearer $COOLIFY_KEY" "$COOLIFY/audit-events"
# Service databases: /services/{uuid}/databases/{database_uuid}/imports

多实例环境

运行多个 Coolify 实例时(例如,在不同服务器上分别运行生产、预发布和开发实例),请遵循以下约定以避免混淆。

环境变量命名

使用带后缀的变量名来区分实例:

# .env structure for multi-instance
COOLIFY_KEY_PROD=3|abc...      # Production instance token
COOLIFY_PROD=https://cool.prod.example.com/api/v1

COOLIFY_KEY_STAGING=5|def...   # Staging instance token  
COOLIFY_STAGING=https://cool.staging.example.com/api/v1

COOLIFY_KEY_DEV=2|ghi...       # Dev instance token
COOLIFY_DEV=https://cool.dev.example.com/api/v1
多实例的 CLI 上下文设置
# Add all instances as named contexts
coolify context add prod https://cool.prod.example.com "$COOLIFY_KEY_PROD"
coolify context add staging https://cool.staging.example.com "$COOLIFY_KEY_STAGING"
coolify context add dev https://cool.dev.example.com "$COOLIFY_KEY_DEV"

# Set default (usually prod)
coolify context set-default prod

# Always verify which context is active before operations
coolify context list
查找托管应用的实例

如果不知道哪个实例托管了特定应用:

# Search across all contexts
for ctx in prod staging dev; do
  echo "=== $ctx ==="
  coolify --context=$ctx app list --format json 2>/dev/null | \
    jq -r '.[] | "\(.name) | \(.fqdn // "no-fqdn")"' | \
    grep -i "your-app-name" || echo "(not found)"
done

诊断部署失败

快速诊断工作流
# 1. List recent deployments for the app
coolify app deployments list <app-uuid> --format json | jq '.[0:3]'

# 2. Check status of latest deployment
coolify app deployments list <app-uuid> --format json | jq '.[0] | {status, commit, finished_at}'

# 3. Get deployment logs (latest)
coolify app deployments logs <app-uuid>

# 4. Get detailed debug logs (shows Docker build output)
coolify app deployments logs <app-uuid> --debuglogs

# 5. Get logs for specific deployment
coolify app deployments logs <app-uuid> <deployment-uuid> --debuglogs
常见构建失败
YAML Frontmatter 解析错误(Astro/MDX 网站)
incomplete explicit mapping pair; a key node is missed

原因: YAML frontmatter 值中包含未加引号的冒号(:)。

# WRONG - colon breaks YAML parser
description: Install this tool: it's great

# CORRECT - quote the value
description: "Install this tool: it's great"
npm ci / npm install 失败
npm ERR! Could not resolve dependency

原因: 锁定文件不匹配或缺少依赖项。

# Fix locally, then push
rm -rf node_modules package-lock.json
npm install
git add package-lock.json
git commit -m "fix: regenerate lock file"
git push
Dockerfile 构建失败
ERROR: failed to solve: process "/bin/sh -c npm run build" did not complete successfully

原因: 容器内的构建命令失败。请检查错误上方的日志行以找到实际故障原因(通常是代码/配置问题,而不是 Docker 问题)。

健康检查超时
Healthcheck failed after X attempts

原因: 应用未能在规定时间内响应配置的健康检查路径/端口。

# Check health check config
coolify app get <uuid> --format json | jq '{health_check_enabled, health_check_path, health_check_port}'

# Common fixes:
# - Increase start period in Coolify UI
# - Verify the health check path returns 200
# - Check if app binds to 0.0.0.0, not 127.0.0.1
解读部署日志 JSON

部署 JSON 中的 logs 字段包含一个日志条目数组:

# Extract just error messages
coolify app deployments list <uuid> --format json | \
  jq -r '.[0].logs' | jq -r '.[] | select(.type == "stderr") | .output'

# Find the actual failure point
coolify app deployments list <uuid> --format json | \
  jq -r '.[0].logs' | jq -r '.[] | select(.output | test("error|ERROR|failed|FAILED"; "i")) | .output'

故障排除

错误:405 Method Not Allowed(v4.2.0+)

更改状态的端点需要使用 POST 方法:

# WRONG
curl -sS "$COOLIFY/applications/{uuid}/start"

# CORRECT
curl -sS -X POST "$COOLIFY/applications/{uuid}/start"

受影响的端点:/start、/stop、/restart、/enable、/disable

错误:403 "You are not allowed to access the API"
  1. 在 <INSTANCE_URL>/settings/advanced 确认已启用 API
  2. 检查 IP 允许列表
  3. Member 角色为只读(v4.2.0+)——若要获得写入权限,请提升角色
  4. 前往 Dashboard → Security → API Tokens 重新生成令牌
错误:401 "Unauthenticated"
# Verify Bearer prefix
Authorization: Bearer YOUR_TOKEN

# CLI: verify context
coolify context verify
错误:持久化存储使用 host_path 时出现 400(v4.3.22+)

持久卷中已移除 host_path。API 会拒绝包含该字段的请求。

# WRONG (v4.3.22+)
--host-path /opt/data  # ❌ Rejected

# CORRECT: use named volumes only
--name my-volume
错误:环境变量名称无效(v4.3.15+)

现在会在构建开始前验证构建时环境变量的名称。无效名称会被拒绝,并显示具体错误消息。

# WRONG
MY-VAR=value      # Hyphens not allowed
2NDVAR=value      # Cannot start with number

# CORRECT
MY_VAR=value
SECOND_VAR=value
达到重启次数上限 — 容器不可见(已在 v4.3.15 修复)

已修复:容器达到重启次数上限后,即使已停止,现在也会显示。可用操作:重试部署、移除容器。

GitLab App 无法通过 API 创建应用程序

在 Coolify 4.3.x 中,POST /applications/private-gitlab-app 会返回 404。请先通过 UI 使用 GitLab App 创建应用程序,然后使用 PATCH /applications/{uuid} 进行编辑。如果 build_pack=dockercompose,请使用 docker_compose_domains,而不是 domains。详情请参阅“GitLab Apps”部分。

错误:context verify 返回 404
# CLI context: URL WITHOUT /api/v1
coolify context add my-coolify http://192.168.1.100:8000 "$TOKEN"

# Direct API: URL WITH /api/v1
COOLIFY=http://192.168.1.100:8000/api/v1
含竖线 (|) 的令牌会导致 shell 出错
# WRONG
source .env

# CORRECT
COOLIFY_KEY=$(sed -n 's/^COOLIFY_KEY=//p' .env)
DNS 解析失败(v4.3.22+ 回退机制)

如果配置的 DNS 解析器未返回地址记录,Coolify 现在会自动回退到系统 DNS 解析器。

大型 Cookie 标头导致 HTTP 400(已在 v4.3.18 修复)

nginx 请求标头缓冲区已增大。如果使用较旧版本,大型 Cookie 标头可能会在请求到达 Coolify 前导致 HTTP 400。


常见工作流

部署新应用程序
# 1. Setup context
coolify context add prod https://coolify.example.com "$TOKEN" --default
coolify context verify

# 2. List servers
coolify server list

# 3. Create application
coolify app create public \
  --server-uuid <server-uuid> \
  --project-uuid <project-uuid> \
  --environment-name production \
  --git-repository "https://github.com/user/repo" \
  --git-branch main \
  --build-pack nixpacks \
  --ports-exposes 3000 \
  --instant-deploy

# 4. Monitor deployment
coolify app deployments logs <uuid> -f
多环境设置
# Add contexts
coolify context add prod https://prod.coolify.io "$PROD_TOKEN" --default
coolify context add staging https://staging.coolify.io "$STAGING_TOKEN"
coolify context add dev https://dev.coolify.io "$DEV_TOKEN"

# Use different contexts
coolify --context=prod app list
coolify --context=staging deploy name api
coolify --context=dev resource list
批量部署
# Deploy multiple services at once
coolify deploy batch api,worker,frontend --force

# Monitor
coolify deploy list
配置定时备份的数据库
# Create database
coolify database create postgresql \
  --server-uuid <uuid> \
  --project-uuid <uuid> \
  --environment-name production \
  --name mydb \
  --instant-deploy

# Configure backup
coolify database backup create <db-uuid> \
  --frequency "0 2 * * *" \
  --enabled \
  --retention-days-locally 7 \
  --save-s3 \
  --s3-storage-uuid <s3-uuid>
从文件读取环境变量
# Sync .env file (updates existing, creates new, keeps others)
coolify app env sync <uuid> --file .env.production --build-time --runtime

# Restart to apply
coolify app restart <uuid>

LLM / AI Agent 集成

对于使用 Coolify CLI 的 AI Agent(建议使用本技能所针对的 v1.10.0 固定版本):


参考资料


更新日志

v3.2 (2026-10-19)
  • 固定使用 coolify-cli v1.10.0 (e1d6094) 和 Coolify v4.4.6
  • 新增 app previews list/get/create/update/logs(完整的预览 CRUD 和运行时日志)
  • 新增 database import start/upload/status 和 service database import ...(从文件、上传、S3 和服务器路径还原)
  • 新增 audit list、integration-token create、app secret-manager set(Doppler/Infisical/Vault)
  • 新增 server registry list/login/check/logout、server remove --force/--delete-from-provider,以及 server add/update 的 --server-role
  • 记录新的 server get --resources 结构(来自 GET /servers/{uuid}/resources 的扁平数组)
  • 新增 sqlite 数据库类型、teams update --build-server-fallback、project environments get、service application logs -n
  • 补充 Coolify v4.4.x 的变更(密钥管理器、审计日志、服务器角色、还原默认值、注册表登录)
v3.1 (2026-09-22)
  • 更新以适配 Coolify v4.3.23
  • 记录了破坏性变更:移除 host_path(v4.3.22)、Sentinel 设为必需(v4.3.19)、重启限制改为选择启用(v4.3.21)
  • 新增按域名覆盖内部端口(v4.3.15+)
  • 新增预览部署运行时日志端点(v4.3.23)
  • 为日志 API 新增 lines=all 参数(v4.3.20)
  • 更新备份文档:S3 流式传输、备份缺失告警(v4.3.18)
  • 新增故障排除条目:拒绝 host_path、环境变量验证、DNS 回退
  • CLI v1.8.0 亮点:令牌隐藏、SMTP/Resend 设置、保留存储数值
v3.0 (2026-09-19)
  • 首个 v3 版本,固定使用 CLI v1.8.0

评论

支持 Markdown