跳到正文
cccskills
免费在 GitHub 公开

docker

Docker best practices: image security, build efficiency, runtime hardening, Compose, local tooling (Colima, OrbStack). Use when writing or reviewing Dockerfiles and Compose files.

中文简介正在准备中。当前显示原文说明。

集成工具Docker
查看安装方法

包含的文件(1)

  • SKILL.md3.2 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Docker

Image security

  • Never run as root. Prefer images with built-in non-root user: distroless nonroot, node user in Node images, nobody in Alpine. Otherwise add non-root user and switch: USER appuser
  • Minimal base: distroless, alpine, or official slim variants
  • Pin by digest or immutable tag. Never FROM node:latest or image: myapp:latest in Compose
  • Multi-stage builds: build in full image, copy only artifact to minimal runtime image
  • No build tools in final image
  • Scan with Trivy or Grype in CI. Fail on critical/high CVEs
  • Multi-arch: build with --platform linux/amd64,linux/arm64 for cross-platform targets

Dockerfile

  • One process per container
  • Enable BuildKit: DOCKER_BUILDKIT=1. Use --mount=type=cache for dependency caches, --mount=type=secret for build-time secrets
  • COPY specific files. Avoid COPY . . when targeted copy suffices
  • Layer order: least → most frequently changed. COPY package.json before COPY src/
  • .dockerignore: exclude .git, node_modules, test files, secrets, .env
  • Explicit WORKDIR. No implicit root working dir
  • ENTRYPOINT for executable, CMD for default args
  • No secrets in ENV, ARG, or RUN — persist in layer history. Use --mount=type=secret
  • HEALTHCHECK on all long-running services

Runtime

  • Read-only root filesystem where possible: --read-only
  • Drop all capabilities, re-add only what's needed: --cap-drop ALL --cap-add NET_BIND_SERVICE
  • No --privileged in production
  • Set resource limits: --memory, --cpus
  • Named volumes for persistent data. No bind mounts in production
  • No secrets via env vars. Use Docker secrets or mounted secret files
  • Log rotation: set --log-opt max-size=10m --log-opt max-file=3. Unbounded logs fill disks

Compose

  • compose.yml for local dev only. Production: Kubernetes, ECS, or equivalent
  • Explicit dependencies: depends_on + condition: service_healthy
  • Named volumes for persistent data. Never rely on container filesystem
  • env_file for local config. Never commit .env with real secrets
  • restart: unless-stopped for crash-resilient services
  • Custom networks per service group. Avoid default bridge
  • profiles: for optional services (e.g. debug tools, mock servers). Keep default startup lean

Maintenance

  • docker system prune -f regularly. Dangling images and stopped containers accumulate fast
  • docker image prune -a to remove unused images. Run in CI after builds
  • Inspect layer bloat with dive before pushing large images

Local tooling

  • Colima: colima start --cpu 4 --memory 8 --disk 60. Default VM is undersized
  • Switch context after start: docker context use colima
  • colima stop when not in use. Idle VM still consumes resources
  • OrbStack: preferred on Apple Silicon — lower memory overhead, faster mounts
  • Both are license-free alternatives to Docker Desktop for teams
  • Lima/Colima: use ~/.lima/<profile> for multiple VM profiles (e.g. arm64, rosetta)

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

aws

免费

AWS best practices: IAM, secrets, networking, security, compute, IaC, ops. Use when building, reviewing, or modifying AWS resources.

中文简介正在准备中。当前显示原文说明。

SumonMSelim/agentguard542026年10月12日 更新

gcp

免费

GCP best practices: IAM, secrets, networking, security, compute, IaC, ops. Use when building, reviewing, or modifying GCP resources.

中文简介正在准备中。当前显示原文说明。

SumonMSelim/agentguard542026年10月12日 更新

go

免费

Idiomatic Go 1.25 practices: errors, interfaces, concurrency, generics, testing, security, tooling. Use when writing or reviewing Go code.

中文简介正在准备中。当前显示原文说明。

SumonMSelim/agentguard542026年10月12日 更新

java

免费

Modern Java practices: design, errors, concurrency, security, testing, tooling. Targets Java 21 LTS baseline; Java 25 LTS features called out explicitly. Use when writing or reviewing Java code.

中文简介正在准备中。当前显示原文说明。

SumonMSelim/agentguard542026年10月12日 更新

Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid overcomplication, make surgical changes, surface assumptions, and define verifiable success criteria.

中文简介正在准备中。当前显示原文说明。

SumonMSelim/agentguard542026年10月12日 更新

Kubernetes best practices: security, workloads, networking, config, operations, GitOps. Use when writing or reviewing K8s manifests and configurations.

中文简介正在准备中。当前显示原文说明。

SumonMSelim/agentguard542026年10月12日 更新

查看 SumonMSelim 的全部技能

报告此技能的问题