container-hardening
它能做什么
这个工具可以帮你提升容器(软件包)的安全性。它会建议如何配置容器,让它们更难被攻击。
适用场景
- ✓当你构建新容器时。
- ✓当你更新现有容器时。
- ✓当安全性是你的高优先级事项时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/container-hardening/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我怎样才能让我的 Docker 容器更安全?”
每周 5 个新技能,1 分钟读完。
工作原理
它会分析你的容器配置并提出修改建议,例如以更少的权限运行容器,或使用更安全的镜像。这些建议会通过代码示例和最佳实践来呈现。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Container Hardening
Secure container images and runtime configurations.
When to Use This Skill
Use this skill when:
- Building secure container images
- Hardening container deployments
- Meeting container security requirements
- Implementing defense in depth
Dockerfile Security
# Example for an application binary already built for this Alpine/musl runtime.
# Pin an approved immutable digest for real builds; refresh supported base images.
FROM alpine:3.24
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup
WORKDIR /app
# Copy only the intended reviewed build artifact, not credentials or the entire repo.
COPY --chown=appuser:appgroup myapp /app/myapp
USER 1001:1001
ENTRYPOINT ["/app/myapp"]
Runtime Security
# Run with security options
docker run -d \
--read-only \
--tmpfs /tmp:rw,noexec,nosuid,size=64m \
--security-opt=no-new-privileges:true \
--cap-drop=ALL \
--user 1001:1001 \
myapp@sha256:<reviewed-image-digest>
Kubernetes Security Context
apiVersion: v1
kind: Pod
metadata:
name: hardened-example
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1001
fsGroup: 1001
containers:
- name: app
image: myapp@sha256:<reviewed-image-digest>
resources:
requests: {cpu: "100m", memory: "64Mi"}
limits: {cpu: "500m", memory: "256Mi"}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
Image Scanning
# Scan with Trivy
trivy image --severity HIGH,CRITICAL myapp@sha256:<reviewed-image-digest>
# Consider a maintained distroless image only when the actual application is compatible;
# FROM belongs in a Dockerfile, not this shell scanning example.
Best Practices
- Use minimal base images
- Run as non-root user
- Enable read-only filesystem
- Drop all capabilities
- Scan images regularly
- Sign and verify images
- Use secrets management
Related Skills
- container-scanning (
container-scanning) - Vulnerability scanning - kubernetes-hardening (
kubernetes-hardening) - K8s security
Limitations
- The Dockerfile needs a reviewed executable myapp built for the selected ABI; it is not bundled. Build dependencies were never installed in this stage, so do not run apk del against a nonexistent virtual group. Prefer a separate builder stage when compilation is needed.
- Replace digest placeholders with verified image identities before execution. The Pod YAML is a template; tune actual resource budgets and approved volumes, network policy and workload permissions. No Docker build, cluster application or scanner execution is claimed.
- Read-only filesystems and dropped capabilities reduce privileges but are not a complete sandbox. Add writable paths only where required; low ports do not justify NET_BIND_SERVICE by default. Scanning can disclose artifacts or use network databases, so review data paths and policies first.
- Docs-only import: upstream scripts and templates not bundled.
Example
# Read-only first: inventory before any active step.
command -v docker
docker --version
Adapted from BagelHole/DevOps-Security-Agent-Skills (MIT); frontmatter, When to Use/Limitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.
常见问题
什么是容器?
容器就像一个盒子,把程序和它运行所需的一切打包在一起,确保它在任何地方都能以相同的方式运行。
为什么容器安全很重要?
不安全的容器可能被黑客利用,从而获取你的数据或干扰你的服务。
这个工具会自动修复问题吗?
不会。它会提供修复说明和示例,但最终的实施由你决定。
详情
作者的原始描述
Secure Docker images and container runtime configurations.
热度
- GitHub 星标
- 48k
- 排名
- #4241
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。