ln-783-container-launcher

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ln-783-container-launcher

ln-783-容器启动器

Type: L3 Worker Category: 7XX Project Bootstrap Parent: ln-780-bootstrap-verifier

类型: L3 工作组件 分类: 7XX 项目启动工具集 父组件: ln-780-启动验证器

Purpose

用途

Builds Docker images, launches containers, and performs comprehensive health verification using Docker native health checks and retry strategies.
Scope:
  • Detect and validate docker-compose.yml configuration
  • Build Docker images
  • Launch containers with proper startup order
  • Verify container health using native health checks
  • Provide access URLs and cleanup instructions
Out of Scope:
  • Building application code (handled by ln-781)
  • Running tests (handled by ln-782)
  • Container orchestration beyond single host (Kubernetes, Swarm)

构建Docker镜像、启动容器,并利用Docker原生健康检查和重试策略执行全面的健康验证。
适用范围:
  • 检测并验证docker-compose.yml配置
  • 构建Docker镜像
  • 按正确启动顺序启动容器
  • 利用原生健康检查验证容器健康状态
  • 提供访问URL和清理说明
不适用范围:
  • 构建应用代码(由ln-781处理)
  • 运行测试(由ln-782处理)
  • 单主机之外的容器编排(如Kubernetes、Swarm)

When to Use

使用场景

ScenarioUse This Skill
Called by ln-780 orchestratorYes
Standalone container launchYes
Development environment setupYes
Production deploymentNo, use proper CI/CD

场景是否使用本组件
由ln-780编排器调用
独立启动容器
开发环境搭建
生产环境部署否,使用专业CI/CD工具

Workflow

工作流程

Step 1: Pre-flight Checks

步骤1:预检检查

Verify Docker environment readiness.
CheckFailure Action
Docker daemon runningReport error with installation instructions
Docker Compose availableReport error, suggest installation
Compose file existsReport error, list expected locations
Required ports freeReport conflict, suggest alternatives
Sufficient disk spaceWarn if low space (<2GB free)
验证Docker环境是否就绪。
检查项失败处理动作
Docker守护进程是否运行报错并提供安装启动说明
Docker Compose是否可用报错并建议安装
Compose文件是否存在报错并列出预期路径
所需端口是否空闲报告端口冲突并建议替代方案
磁盘空间是否充足空间不足时发出警告(剩余空间<2GB)

Step 2: Parse Compose Configuration

步骤2:解析Compose配置

Extract service information from docker-compose.yml.
InformationPurpose
Service namesTrack which containers to monitor
Exposed portsKnow which ports to check
Health check definitionsUse native health checks if defined
Dependencies (depends_on)Understand startup order
Volume mountsVerify paths exist
从docker-compose.yml中提取服务信息。
信息内容用途
服务名称跟踪需要监控的容器
暴露端口明确需要检查的端口
健康检查定义若已定义则使用原生健康检查
依赖关系(depends_on)明确启动顺序
卷挂载验证挂载路径是否存在

Step 3: Build Images

步骤3:构建镜像

Build all images defined in compose file.
AspectStrategy
Build contextUse paths from compose file
Build argsPass through from compose configuration
CacheUse Docker layer cache for speed
FailureReport build errors with full log
构建Compose文件中定义的所有镜像。
方面策略
构建上下文使用Compose文件中指定的路径
构建参数直接传递Compose配置中的参数
缓存利用Docker层缓存提升速度
失败处理报错并提供完整构建日志

Step 4: Launch Containers

步骤4:启动容器

Start containers with proper orchestration.
AspectStrategy
Startup orderRespect depends_on and healthcheck conditions
Detached modeRun in background
NetworkUse compose-defined networks
VolumesMount all defined volumes
按合理编排逻辑启动容器。
方面策略
启动顺序遵循depends_on和健康检查条件
后台模式在后台运行容器
网络使用Compose定义的网络
挂载所有已定义的卷

Step 5: Health Verification

步骤5:健康验证

Verify all containers are healthy using appropriate strategy.
Strategy Selection:
ConditionStrategy
Service has
healthcheck:
in compose
Use native Docker health status
Service has
depends_on: condition: service_healthy
Wait for Docker health status
No healthcheck definedUse external HTTP probe with retry
Retry Configuration:
ParameterValueRationale
Max attempts10Allow slow-starting services
Initial delay5sGive containers time to start
BackoffExponential (5, 10, 20, 40s)Avoid overwhelming services
Max total wait120sReasonable upper limit
Health Check Methods:
MethodWhen to Use
Docker health statusWhen container has healthcheck defined
HTTP GET to exposed portFor web services without healthcheck
Container execFor services without exposed ports
TCP port checkFor databases and message queues
采用合适策略验证所有容器是否健康。
策略选择:
条件策略
服务在Compose中定义了
healthcheck:
使用Docker原生健康状态
服务定义了
depends_on: condition: service_healthy
等待Docker健康状态
未定义健康检查使用外部HTTP探测并重试
重试配置:
参数取值理由
最大尝试次数10为启动较慢的服务预留时间
初始延迟5秒给容器启动预留时间
退避策略指数退避(5、10、20、40秒)避免压垮服务
最长总等待时间120秒合理的上限值
健康检查方法:
方法使用场景
Docker健康状态容器已定义健康检查时
向暴露端口发送HTTP GET请求无健康检查的Web服务
容器内执行命令无暴露端口的服务
TCP端口检查数据库和消息队列服务

Step 6: Report Results

步骤6:结果报告

Return structured results to orchestrator.
Result Structure:
FieldDescription
containersArray of container status objects
healthChecksArray of health check results
accessUrlsMap of service name to access URL
overallStatushealthy / unhealthy / partial
startupDurationTime from launch to all healthy
Container Status Object:
FieldDescription
nameContainer name
serviceService name from compose
statusrunning / exited / restarting
healthhealthy / unhealthy / starting / none
portExposed port (if any)
startedAtContainer start timestamp
Health Check Result:
FieldDescription
urlChecked URL or endpoint
statusHTTP status code or check result
responseTimeTime to respond in ms
healthyBoolean health status

向编排器返回结构化结果。
结果结构:
字段描述
containers容器状态对象数组
healthChecks健康检查结果数组
accessUrls服务名称到访问URL的映射
overallStatus健康/不健康/部分健康
startupDuration从启动到全部健康的耗时
容器状态对象:
字段描述
name容器名称
serviceCompose中的服务名称
status运行中/已退出/重启中
health健康/不健康/启动中/无健康检查
port暴露端口(如有)
startedAt容器启动时间戳
健康检查结果:
字段描述
url检查的URL或端点
statusHTTP状态码或检查结果
responseTime响应时间(毫秒)
healthy健康状态布尔值

Error Handling

错误处理

Error TypeAction
Docker daemon not runningReport with start instructions
Port already in useReport conflict, suggest docker compose down first
Image build failedReport with build logs
Container exitedReport with container logs
Health check timeoutReport with last known status and logs
Network unreachableCheck Docker network configuration

错误类型处理动作
Docker守护进程未运行报错并提供启动说明
端口已被占用报告冲突并建议先执行docker compose down
镜像构建失败报错并提供构建日志
容器已退出报错并提供容器日志
健康检查超时报错并提供最后已知状态和日志
网络不可达检查Docker网络配置

Options

可选配置

OptionDefaultDescription
keepRunningtrueLeave containers running after verification
stopAfterfalseStop containers after successful verification
healthTimeout120Max seconds to wait for healthy status
showLogstrueShow container logs on failure
buildFirsttrueBuild images before starting
pullLatestfalsePull base images before build

选项默认值说明
keepRunningtrue验证完成后保持容器运行
stopAfterfalse验证成功后停止容器
healthTimeout120等待健康状态的最长秒数
showLogstrue失败时显示容器日志
buildFirsttrue启动前先构建镜像
pullLatestfalse构建前拉取最新基础镜像

Cleanup Instructions

清理说明

Provide user with cleanup commands in report.
ActionDescription
Stop containersStop running containers, preserve data
Remove containers and networksClean up containers but keep volumes
Remove everythingFull cleanup including volumes and images

在报告中为用户提供清理命令。
操作说明
停止容器停止运行中的容器,保留数据
删除容器和网络清理容器但保留卷
完全清理清理所有内容,包括卷和镜像

Critical Rules

核心规则

  1. Use native health checks when available - more reliable than external probes
  2. Implement retry with backoff - services need time to initialize
  3. Always collect logs on failure - essential for debugging
  4. Parse compose file for ports - do not hardcode port numbers
  5. Respect depends_on order - critical for database-dependent services

  1. 优先使用原生健康检查 - 比外部探测更可靠
  2. 实现带退避的重试机制 - 服务需要时间初始化
  3. 失败时务必收集日志 - 对调试至关重要
  4. 从Compose文件解析端口 - 不要硬编码端口号
  5. 遵循depends_on顺序 - 对依赖数据库的服务至关重要

Definition of Done

完成标准

  • Docker environment verified
  • All images built successfully
  • All containers running
  • All health checks passing
  • Access URLs provided
  • Results returned to orchestrator

Version: 2.0.0 Last Updated: 2026-01-10
  • Docker环境已验证
  • 所有镜像构建成功
  • 所有容器正在运行
  • 所有健康检查通过
  • 已提供访问URL
  • 结果已返回给编排器

版本: 2.0.0 最后更新时间: 2026-01-10