create-docker-healthcheck
Generates Docker health check scripts for PHP services. Creates PHP-FPM, Nginx, and custom endpoint health checks.
Best use case
create-docker-healthcheck is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Generates Docker health check scripts for PHP services. Creates PHP-FPM, Nginx, and custom endpoint health checks.
Teams using create-docker-healthcheck should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/create-docker-healthcheck/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How create-docker-healthcheck Compares
| Feature / Agent | create-docker-healthcheck | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Generates Docker health check scripts for PHP services. Creates PHP-FPM, Nginx, and custom endpoint health checks.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Docker Health Check Generator
Generates health check scripts and configurations for PHP Docker containers.
## Generated Files
```
docker/healthcheck/
php-fpm-healthcheck.sh # PHP-FPM process health check
http-healthcheck.sh # HTTP endpoint health check
combined-healthcheck.sh # Combined multi-service check
```
## PHP-FPM Health Check (cgi-fcgi based)
```bash
#!/bin/bash
# php-fpm-healthcheck.sh
# Checks PHP-FPM status via /ping endpoint using cgi-fcgi
set -eo pipefail
FCGI_CONNECT="${FCGI_CONNECT:-localhost:9000}"
FCGI_STATUS_PATH="${FCGI_STATUS_PATH:-/ping}"
EXPECTED_RESPONSE="${EXPECTED_RESPONSE:-pong}"
if ! command -v cgi-fcgi &> /dev/null; then
echo "ERROR: cgi-fcgi not found. Install libfcgi-bin."
exit 1
fi
RESPONSE=$(SCRIPT_NAME="${FCGI_STATUS_PATH}" \
SCRIPT_FILENAME="${FCGI_STATUS_PATH}" \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect "${FCGI_CONNECT}" 2>/dev/null)
if echo "${RESPONSE}" | grep -q "${EXPECTED_RESPONSE}"; then
echo "OK: PHP-FPM is healthy"
exit 0
else
echo "FAIL: PHP-FPM returned unexpected response"
exit 1
fi
```
### PHP-FPM Pool Configuration (required)
```ini
; /usr/local/etc/php-fpm.d/www.conf
; Enable ping/status endpoints
pm.status_path = /status
ping.path = /ping
ping.response = pong
```
## HTTP Endpoint Health Check (curl-based)
```bash
#!/bin/bash
# http-healthcheck.sh
# Checks application health via HTTP /health endpoint
set -eo pipefail
HEALTH_URL="${HEALTH_URL:-http://localhost:80/health}"
TIMEOUT="${HEALTH_TIMEOUT:-5}"
EXPECTED_STATUS="${EXPECTED_STATUS:-200}"
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
--max-time "${TIMEOUT}" \
--fail \
"${HEALTH_URL}" 2>/dev/null) || true
if [ "${RESPONSE_CODE}" = "${EXPECTED_STATUS}" ]; then
echo "OK: HTTP health check passed (${RESPONSE_CODE})"
exit 0
else
echo "FAIL: HTTP health check returned ${RESPONSE_CODE}, expected ${EXPECTED_STATUS}"
exit 1
fi
```
## Combined Health Check Script
```bash
#!/bin/bash
# combined-healthcheck.sh
# Checks PHP-FPM process + custom application logic
set -eo pipefail
FCGI_CONNECT="${FCGI_CONNECT:-localhost:9000}"
HEALTH_URL="${HEALTH_URL:-http://localhost:80/health}"
# Check 1: PHP-FPM process is running
if ! pgrep -x "php-fpm" > /dev/null 2>&1; then
echo "FAIL: PHP-FPM process not running"
exit 1
fi
# Check 2: PHP-FPM responds to ping
PING_RESPONSE=$(SCRIPT_NAME=/ping \
SCRIPT_FILENAME=/ping \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect "${FCGI_CONNECT}" 2>/dev/null || true)
if ! echo "${PING_RESPONSE}" | grep -q "pong"; then
echo "FAIL: PHP-FPM not responding to ping"
exit 1
fi
# Check 3: Application health endpoint
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
--max-time 5 "${HEALTH_URL}" 2>/dev/null || true)
if [ "${HTTP_CODE}" != "200" ]; then
echo "FAIL: Application health endpoint returned ${HTTP_CODE}"
exit 1
fi
echo "OK: All health checks passed"
exit 0
```
## Dockerfile HEALTHCHECK Instruction
```dockerfile
# Simple PHP-FPM health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD ["php-fpm-healthcheck"] || exit 1
# HTTP endpoint health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD curl -f http://localhost:80/health || exit 1
# Combined health check (copy script into image)
COPY docker/healthcheck/combined-healthcheck.sh /usr/local/bin/healthcheck
RUN chmod +x /usr/local/bin/healthcheck
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD ["/usr/local/bin/healthcheck"]
```
## Docker Compose Health Check Format
```yaml
# docker-compose.yml
services:
php-fpm:
build: .
healthcheck:
test: ["CMD", "/usr/local/bin/healthcheck"]
interval: 30s
timeout: 5s
start_period: 20s
retries: 3
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
MYSQL_DATABASE: "${DB_NAME}"
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_PASSWORD}"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 5
postgres:
image: postgres:16-alpine
environment:
POSTGRES_DB: "${DB_NAME}"
POSTGRES_USER: "${DB_USER}"
POSTGRES_PASSWORD: "${DB_PASSWORD}"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
interval: 10s
timeout: 5s
start_period: 30s
retries: 5
redis:
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
start_period: 5s
retries: 3
rabbitmq:
image: rabbitmq:3-management-alpine
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "check_running"]
interval: 15s
timeout: 10s
start_period: 30s
retries: 5
```
## Dependency Wait Pattern
```yaml
# docker-compose.yml — services wait for healthy dependencies
services:
php-fpm:
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
rabbitmq:
condition: service_healthy
```
## Generation Instructions
1. **Analyze project stack:**
- Identify PHP-FPM version
- Check for Nginx reverse proxy
- List dependent services (MySQL, PostgreSQL, Redis, RabbitMQ)
2. **Generate health check scripts:**
- PHP-FPM ping check for all setups
- HTTP endpoint check if application exposes /health
- Combined check for production deployments
3. **Configure Dockerfile:**
- Add HEALTHCHECK instruction
- Copy health check scripts
- Set proper permissions (chmod +x)
4. **Configure docker-compose:**
- Add healthcheck blocks for each service
- Use `depends_on` with `condition: service_healthy`
- Tune intervals for each service type
## Usage
Provide:
- Services in the stack (PHP-FPM, MySQL, Redis, etc.)
- Health endpoint URL (if application provides one)
- Desired check intervals and thresholds
- Deployment target (development/production)
The generator will:
1. Create appropriate health check scripts
2. Add Dockerfile HEALTHCHECK instructions
3. Configure docker-compose healthcheck blocks
4. Set up dependency ordering with health conditionsRelated Skills
optimize-docker-startup
Optimizes Docker container startup time for PHP applications. Reduces initialization overhead through preloading, caching, and entrypoint optimization.
optimize-docker-php-fpm
Optimizes PHP-FPM configuration in Docker containers. Tunes process manager, request handling, and resource allocation for production workloads.
optimize-docker-opcache
Optimizes OPcache configuration for PHP Docker containers. Configures memory, file limits, JIT, and validation for production and development.
optimize-docker-layers
Analyzes and optimizes Docker layer caching for PHP projects. Identifies layer ordering issues, cache invalidation problems, and provides recommendations for faster builds.
optimize-docker-image-size
Optimizes Docker image size for PHP projects. Reduces image footprint through Alpine, multi-stage builds, layer cleanup, and dependency minimization.
optimize-docker-compose-resources
Optimizes Docker Compose resource allocation for PHP stacks. Configures memory limits, CPU constraints, and service scaling.
optimize-docker-build-time
Optimizes Docker build time for PHP projects. Analyzes layer caching, BuildKit features, parallel builds, and dependency installation.
docker-troubleshooting-knowledge
Docker troubleshooting knowledge base. Provides debugging patterns, common error solutions, and diagnostic commands for PHP containers.
docker-security-knowledge
Docker security knowledge base for PHP. Provides hardening patterns, vulnerability scanning, secrets management, and OWASP container guidelines.
docker-scanning-knowledge
Docker image scanning knowledge base. Provides vulnerability detection, compliance checking, and SBOM generation for PHP container images.
docker-production-knowledge
Docker production knowledge base for PHP. Provides deployment patterns, health checks, graceful shutdown, logging, and monitoring.
docker-php-extensions-knowledge
Docker PHP extensions knowledge base. Provides installation patterns for common extensions, build dependency management, and PECL usage.