container-hardening – skill DevOps & Hạ tầng cho agent AI
Bảo mật image Docker và cấu hình runtime của container.
Cài skill container-hardening bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/container-hardening-9aa92.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /container-hardening – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/container-hardening-9aa92.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $container-hardening – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/container-hardening-9aa92.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /container-hardening – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/container-hardening-9aa92.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /container-hardening – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
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:REPLACE_WITH_REVIEWED_DIGESTKubernetes Security Context
apiVersion: v1
kind: Pod
metadata:
name: hardened-example
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1001
fsGroup: 1001
containers:
- name: app
image: myapp@sha256:REPLACE_WITH_REVIEWED_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 --exit-code 1 --severity HIGH,CRITICAL myapp@sha256:REPLACE_WITH_REVIEWED_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](https://github.com/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.
Skill liên quan
- container-registries – Quản lý container registry gồm ECR, ACR, GCR và Docker Hub.
- cost-optimization – Chiến lược và mẫu tối ưu chi phí cloud trên AWS, Azure và GCP.
- secrets-management – Triển khai quản lý secrets an toàn cho pipeline CI/CD bằng Vault, AWS Secrets Manager…
- service-mesh-observability – Triển khai khả năng quan sát toàn diện cho service mesh, bao gồm distributed tracing…
- shellcheck-configuration – Nắm vững cấu hình và cách dùng ShellCheck để phân tích tĩnh chất lượng shell script…
- slo-implementation – Định nghĩa và triển khai Service Level Indicators (SLIs) và Service Level Objectives…
- database-cloud-optimization-cost-optimize – Bạn là chuyên gia tối ưu chi phí cloud, chuyên giảm chi phí hạ tầng mà vẫn giữ hiệu năng…
- datadog – Triển khai giám sát Datadog và APM cho hạ tầng và ứng dụng.