kool-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseKool CLI
Kool CLI
Kool simplifies Docker-based development with commands for container lifecycle, service execution, and custom scripts.
Kool 通过容器生命周期管理、服务执行和自定义脚本相关命令,简化基于Docker的开发工作。
Quick Reference
快速参考
bash
kool start # Start all services from docker-compose.yml
kool stop # Stop all services
kool restart --rebuild # Restart and rebuild images
kool status # Show running containers
kool exec <service> <cmd> # Run command in service container
kool logs -f <service> # Follow service logs
kool run --json # List available scripts as JSON
kool run <script> # Run a script from kool.ymlbash
kool start # Start all services from docker-compose.yml
kool stop # Stop all services
kool restart --rebuild # Restart and rebuild images
kool status # Show running containers
kool exec <service> <cmd> # Run command in service container
kool logs -f <service> # Follow service logs
kool run --json # List available scripts as JSON
kool run <script> # Run a script from kool.ymlService Lifecycle
服务生命周期
Services are defined in . Kool wraps docker-compose with simpler commands.
docker-compose.ymlbash
kool start # Start all services
kool start app database # Start specific services
kool start --rebuild # Rebuild images before starting
kool start --foreground # Run in foreground (see logs)
kool start --profile worker # Enable a docker-compose profile
kool stop # Stop all services
kool stop app # Stop specific service
kool stop --purge # Stop and remove volumes (destructive)
kool restart # Restart all services
kool restart --rebuild # Rebuild images on restart
kool restart --purge # Purge volumes on restart
kool status # Show status of all containers服务在中定义。Kool 对docker-compose进行了封装,提供更简洁的命令。
docker-compose.ymlbash
kool start # Start all services
kool start app database # Start specific services
kool start --rebuild # Rebuild images before starting
kool start --foreground # Run in foreground (see logs)
kool start --profile worker # Enable a docker-compose profile
kool stop # Stop all services
kool stop app # Stop specific service
kool stop --purge # Stop and remove volumes (destructive)
kool restart # Restart all services
kool restart --rebuild # Rebuild images on restart
kool restart --purge # Purge volumes on restart
kool status # Show status of all containersExecuting Commands in Containers
在容器中执行命令
Use to run commands inside running service containers (like SSH).
execbash
kool exec <service> <command>
kool exec app bash # Interactive shell
kool exec app php artisan migrate # Run Laravel migration
kool exec app npm install # Install npm packages
kool exec -e VAR=value app env # With environment variable使用在运行的服务容器中执行命令(类似SSH)。
execbash
kool exec <service> <command>
kool exec app bash # Interactive shell
kool exec app php artisan migrate # Run Laravel migration
kool exec app npm install # Install npm packages
kool exec -e VAR=value app env # With environment variableOne-off Docker Containers
一次性Docker容器
Use to run commands in temporary containers (not services).
dockerbash
kool docker <image> <command>
kool docker node npm init # Run npm in node container
kool docker --volume=$PWD:/app golang go build # Mount current dir
kool docker --env=DEBUG=1 python python script.py # With env var
kool docker --publish=3000:3000 node npm start # Expose port使用在临时容器(非服务容器)中执行命令。
dockerbash
kool docker <image> <command>
kool docker node npm init # Run npm in node container
kool docker --volume=$PWD:/app golang go build # Mount current dir
kool docker --env=DEBUG=1 python python script.py # With env var
kool docker --publish=3000:3000 node npm start # Expose portViewing Logs
查看日志
bash
kool logs # Last 25 lines from all services
kool logs app # Logs from specific service
kool logs -f # Follow logs (live)
kool logs -f app worker # Follow multiple services
kool logs --tail 100 # Last 100 lines
kool logs --tail 0 # All logsbash
kool logs # Last 25 lines from all services
kool logs app # Logs from specific service
kool logs -f # Follow logs (live)
kool logs -f app worker # Follow multiple services
kool logs --tail 100 # Last 100 lines
kool logs --tail 0 # All logsProject Scripts
项目脚本
Scripts are defined in and provide project-specific commands.
kool.ymlbash
kool run --json # List scripts as JSON [{name, comments, commands}]
kool run # List scripts (human-readable)
kool run <script> # Run a script
kool run <script> -- <args> # Pass args (single-line scripts only)
kool run -e VAR=1 <script> # Run with environment variable脚本在中定义,用于提供项目专属命令。
kool.ymlbash
kool run --json # List scripts as JSON [{name, comments, commands}]
kool run # List scripts (human-readable)
kool run <script> # Run a script
kool run <script> -- <args> # Pass args (single-line scripts only)
kool run -e VAR=1 <script> # Run with environment variableGlobal Options
全局选项
All commands support:
bash
-w, --working_dir <path> # Run from different directory
--verbose # Increase output verbosity所有命令均支持:
bash
-w, --working_dir <path> # Run from different directory
--verbose # Increase output verbosityImportant Rules
重要规则
- ALWAYS run from project root (has and
docker-compose.yml) or usekool.yml.-w - Service names come from service definitions.
docker-compose.yml - Script args only work with single-line scripts; multi-line scripts reject extra args.
- Scripts in are not full bash - use
kool.ymlfor pipes/conditionals.kool docker <image> bash -c "..."
- 始终从项目根目录(包含和
docker-compose.yml)运行,或使用kool.yml选项指定目录。-w - 服务名称来自中的服务定义。
docker-compose.yml - 脚本参数仅适用于单行脚本;多行脚本会拒绝额外参数。
- kool.yml中的脚本并非完整的bash脚本;如需使用管道/条件语句,请使用。
kool docker <image> bash -c "..."