docker-security-knowledge
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "docker-security-knowledge":https://skillpi.com/zh/skills/deepskill-47af178eb56b9a25631370e2194520a875ef77a055fdfb227e6ef0606b9020c5。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
针对 PHP 的 Docker 安全知识库,提供有关加固模式、漏洞扫描、密钥管理以及 OWASP 容器安全指南的说明与参考资料。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: docker-security-knowledge
description: Docker security knowledge base for PHP. Provides hardening patterns, vulnerability scanning, secrets management, and OWASP container guidelines.Docker Security Knowledge Base
Quick reference for Docker security hardening patterns in PHP applications.
Security Layers
+---------------------------------------------------------------------------+
| DOCKER SECURITY LAYERS |
+---------------------------------------------------------------------------+
| |
| Layer 1: Build Security |
| +--------------------------------------------------------------------+ |
| | Minimal base image | Pinned versions | No secrets in layers | |
| | Multi-stage builds | .dockerignore | Verified base images | |
| +--------------------------------------------------------------------+ |
| |
| Layer 2: Image Security |
| +--------------------------------------------------------------------+ |
| | Vulnerability scanning | SBOM generation | Signed images | |
| | No unnecessary packages | Read-only layers | Minimal attack surface | |
| +--------------------------------------------------------------------+ |
| |
| Layer 3: Runtime Security |
| +--------------------------------------------------------------------+ |
| | Non-root user | Read-only filesystem | Dropped capabilities | |
| | Resource limits | No privileged mode | Seccomp profiles | |
| +--------------------------------------------------------------------+ |
| |
| Layer 4: Network Security |
| +--------------------------------------------------------------------+ |
| | Network segmentation | Encrypted traffic | Internal DNS only | |
| | No host networking | Firewall rules | Service mesh (optional) | |
| +--------------------------------------------------------------------+ |
| |
| Layer 5: Secrets Management |
| +--------------------------------------------------------------------+ |
| | Docker secrets | Build secrets | External vault | |
| | No ENV for secrets | Encrypted at rest | Rotation policies | |
| +--------------------------------------------------------------------+ |
| |
+---------------------------------------------------------------------------+
Non-Root User Patterns
Alpine-based Image
# syntax=docker/dockerfile:1
FROM php:8.4-fpm-alpine
# Create non-root user and group
RUN addgroup -g 1000 -S app && \
adduser -u 1000 -S app -G app -h /home/app -s /bin/sh
# Set working directory with correct ownership
WORKDIR /var/www/html
RUN chown -R app:app /var/www/html
# Switch to non-root user
USER app
Debian-based Image
FROM php:8.4-fpm
RUN groupadd -g 1000 app && \
useradd -u 1000 -g app -m -s /bin/bash app
WORKDIR /var/www/html
RUN chown -R app:app /var/www/html
USER app
Secrets Management
Build Secrets (BuildKit)
# syntax=docker/dockerfile:1
FROM composer:2 AS deps
# Use build secret for private repository access
RUN --mount=type=secret,id=composer_auth,target=/root/.composer/auth.json \
composer install --no-dev --no-scripts --prefer-dist
FROM php:8.4-fpm-alpine AS production
COPY --from=deps /app/vendor /var/www/html/vendor
# Secret is NOT present in final image
# Build with secret
DOCKER_BUILDKIT=1 docker build \
--secret id=composer_auth,src=auth.json \
-t myapp:latest .
Runtime Secrets (Docker Compose)
services:
php:
image: myapp:latest
secrets:
- db_password
- app_key
secrets:
db_password:
file: ./secrets/db_password.txt
app_key:
file: ./secrets/app_key.txt
<?php
// Read secret at runtime
function getSecret(string $name): string
{
$path = '/run/secrets/' . $name;
if (!file_exists($path)) {
throw new \RuntimeException("Secret not found: {$name}");
}
return trim(file_get_contents($path));
}
Docker Swarm Secrets
# Create encrypted secret
echo "s3cur3p@ss" | docker secret create db_password -
# Use in service
docker service create \
--secret db_password \
--name php-app myapp:latest
Image Scanning Tools
| Tool | Integration | License | Features |
|---|---|---|---|
| Trivy | CLI, CI, Kubernetes | Apache 2.0 | OS + app deps, IaC, SBOM |
| Grype | CLI, CI | Apache 2.0 | OS + app deps, fast |
| Snyk | CLI, CI, IDE | Commercial | Deep analysis, fix advice |
| Docker Scout | Docker Desktop, CLI | Commercial | Policy, SBOM, real-time |
Quick Scan Commands
# Trivy - comprehensive scan
trivy image --severity HIGH,CRITICAL myapp:latest
# Grype - fast vulnerability scan
grype myapp:latest --fail-on high
# Docker Scout - built-in scanning
docker scout cves myapp:latest
docker scout recommendations myapp:latest
Capability Management
# docker-compose.yml
services:
php:
cap_drop:
- ALL
cap_add:
- NET_BIND_SERVICE # Bind to ports < 1024 (if needed)
- CHOWN # Change file ownership (if needed)
security_opt:
- no-new-privileges:true
Minimal Capabilities for PHP-FPM
| Capability | Required | Reason |
|---|---|---|
CHOWN |
Sometimes | File ownership changes |
SETUID |
No | Drop if non-root |
SETGID |
No | Drop if non-root |
NET_BIND_SERVICE |
Rarely | Only for ports < 1024 |
SYS_PTRACE |
No | Debugging only |
ALL |
Drop | Always drop all first |
Read-Only Filesystem
services:
php:
read_only: true
tmpfs:
- /tmp:size=64M
- /var/run:size=1M
- /var/log:size=32M
volumes:
- php-sessions:/var/lib/php/sessions
Network Policies
services:
nginx:
networks:
- frontend
- backend
php:
networks:
- backend # No direct external access
postgres:
networks:
- backend # Database isolated
networks:
frontend:
driver: bridge
backend:
driver: bridge
internal: true # No external access
OWASP Docker Top 10
| # | Risk | Mitigation |
|---|---|---|
| D01 | Secure user mapping | Run as non-root, USER directive |
| D02 | Patch management | Regular base image updates, scanning |
| D03 | Network segmentation | Internal networks, no host mode |
| D04 | Secure defaults | Drop capabilities, read-only FS |
| D05 | Content trust | Signed images, verified publishers |
| D06 | Vulnerability management | Automated scanning in CI/CD |
| D07 | Resource protection | CPU/memory limits, ulimits |
| D08 | Log management | Centralized logging, no sensitive data |
| D09 | Secret management | Docker secrets, external vaults |
| D10 | Integrity and authenticity | Image signing, content trust |
Detection Patterns
# Find Dockerfiles with security issues
Grep: "FROM.*:latest" --glob "**/Dockerfile*"
Grep: "USER root" --glob "**/Dockerfile*"
Grep: "privileged.*true" --glob "**/docker-compose*.yml"
Grep: "ENV.*PASSWORD|ENV.*SECRET|ENV.*KEY" --glob "**/Dockerfile*"
Grep: "cap_add.*ALL|cap_add.*SYS_ADMIN" --glob "**/docker-compose*.yml"
# Check for proper security measures
Grep: "USER app|USER www-data|USER nobody" --glob "**/Dockerfile*"
Grep: "cap_drop.*ALL" --glob "**/docker-compose*.yml"
Grep: "read_only.*true" --glob "**/docker-compose*.yml"
Grep: "no-new-privileges" --glob "**/docker-compose*.yml"
References
For detailed information, load these reference files:
references/security-checklist.md-- Comprehensive security checklist with 50+ items
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 Docker 五层安全架构(构建、镜像、运行时、网络、密钥),覆盖 PHP 应用容器化部署的核心安全需求
- 包含具体加固代码示例(非 root 用户、只读文件系统、能力管理)和主流漏洞扫描工具集成方案
亮点
- description 精准描述 Skill 功能范围,涵盖 Docker 安全加固、漏洞扫描、密钥管理和 OWASP 指南
- 触发词边界清晰,避免与其他通用 Docker 工具混淆
亮点
- 文档结构层次分明,从安全分层到具体实现模式,逻辑清晰
- 每章节配有可执行代码示例和检测模式,便于用户直接应用
亮点
- 所有 Dockerfile 和 compose 配置语法正确,符合最佳实践
- 密钥管理示例包含运行时异常处理,提升执行健壮性
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。