| 定义 | 服务下 profiles: [debug](可多个) |
|---|---|
| 启用 | docker compose --profile debug up -d |
| 默认服务 | 未定义 profiles 的服务始终参与启动 |
| 查看 | docker compose config --profiles |
| 禁用 | COMPOSE_PROFILES 环境变量可预设启用列表 |
示例
示例
services:
web:
image: nginx:1.27-alpine
adminer:
image: adminer:4
profiles: [debug]
ports:
- "127.0.0.1:8081:8080"
启用调试组件
启用调试组件
docker compose --profile debug up -d
docker compose --profile debug psprofiles 把『常驻栈』与『偶尔用』分离,既避免占资源,也防止调试端口长期暴露。