Provides best practices for Dockerfile creation focusing on security, image size, and reliability.
Install
mkdir -p .claude/skills/docker-container-standards && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/18766" && unzip -o skill.zip -d .claude/skills/docker-container-standards && rm skill.zipInstalls to .claude/skills/docker-container-standards
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Standard Docker container rules for packaging services securely and with optimized builds. Covers HEALTHCHECK, non-root user, multi-stage builds, layer caching, and .dockerignore.Key capabilities
- →Run containers as a non-root user
- →Use minimal base images
- →Define a HEALTHCHECK instruction
- →Use exec form for CMD to pass signals properly
- →Separate dependency install from application code copy
- →Use multi-stage builds
How it works
The skill applies rules for security, reliability, and build performance. It ensures non-root user execution, minimal base images, health checks, and optimized layer caching through multi-stage builds and .dockerignore.
Inputs & outputs
When to use docker-container-standards
- →Optimizing Dockerfile builds
- →Securing container images
- →Implementing health checks
About this skill
Docker Container Standards
Best practices for containerized applications. Focus on security, size, speed, and reliability.
Rules
1. Security First
- Non-Root User: Never run containers as root. Create a dedicated user (
appuser/node) and switch to it usingUSER. - Minimal Base Images: Use small, secure base images (e.g.,
python:3.12-slimornode:20-alpine/distroless). - No Secrets: Never hardcode secrets in Dockerfiles. Use environment variables.
2. Reliability & Health
- HEALTHCHECK: Always define a
HEALTHCHECKinstruction using curl/wget or custom health probe. - Signal Handling: Use
execform forCMD(e.g.CMD ["python", "app.py"]instead of shell formCMD python app.py) to pass signals (likeSIGTERM) properly.
3. Build Performance (Layer Caching)
- Separate Dependency Install: Copy dependency manifests (
package.json,pyproject.toml,requirements.txt) and install dependencies before copying application code. - Multi-Stage Builds: Separate build dependencies from runtime environment to keep the final image as light as possible.
- Dockerignore: Exclude
__pycache__,node_modules,.git,.env, and local caches in.dockerignore.
Code Templates
Python Slim Dockerfile Example
# Stage 1: Build dependencies
FROM python:3.12-slim AS builder
WORKDIR /app
RUN pip install --no-cache-dir uv
COPY pyproject.toml uv.lock ./
RUN uv pip install --system --no-cache -r pyproject.toml
# Stage 2: Runtime image
FROM python:3.12-slim
WORKDIR /app
# Copy dependencies from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY . .
# Set non-root user
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Anti-Patterns
| ❌ Don't | ✅ Do instead |
|---|---|
USER root or not specifying USER | RUN useradd appuser && USER appuser |
CMD python app.py (shell form) | CMD ["python", "app.py"] (exec form) |
Missing HEALTHCHECK | Add explicit HEALTHCHECK statement |
| Copying code before dependency install | Copy lockfiles, run install, then copy source code |
Including .git or .env in final image | Define .dockerignore containing sensitive/local files |
When not to use it
- →When security is not a concern
- →When container size and build speed are not priorities
- →When `USER root` is explicitly required
Limitations
- →Never run containers as root
- →Never hardcode secrets in Dockerfiles
- →Always define a HEALTHCHECK instruction
How it compares
This skill provides specific, best-practice-driven rules for Docker containerization focusing on security, size, speed, and reliability, unlike general Docker usage.
Compared to similar skills
docker-container-standards side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| docker-container-standards (this skill) | 0 | 1mo | Caution | Intermediate |
| docker-expert | 11 | 6mo | Review | Intermediate |
| deployment-engineer | 4 | 3mo | No flags | Advanced |
| devops | 2 | 6mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
docker-expert
davila7
Docker containerization expert with deep knowledge of multi-stage builds, image optimization, container security, Docker Compose orchestration, and production deployment patterns. Use PROACTIVELY for Dockerfile optimization, container issues, image size problems, security hardening, networking, and orchestration challenges.
deployment-engineer
sickn33
Expert deployment engineer specializing in modern CI/CD pipelines, GitOps workflows, and advanced deployment automation. Masters GitHub Actions, ArgoCD/Flux, progressive delivery, container security, and platform engineering. Handles zero-downtime deployments, security scanning, and developer experience optimization. Use PROACTIVELY for CI/CD design, GitOps implementation, or deployment automation.
devops
mrgoonie
Deploy to Cloudflare (Workers, R2, D1), Docker, GCP (Cloud Run, GKE), Kubernetes (kubectl, Helm). Use for serverless, containers, CI/CD, GitOps, security audit.
ecs
itsmostafa
AWS ECS container orchestration for running Docker containers. Use when deploying containerized applications, configuring task definitions, setting up services, managing clusters, or troubleshooting container issues.
add-install-docker-ci-e2e
RLinf
Adds install command in install script, Docker build stage in Dockerfile, and CI jobs for docker build, install script, and embodied e2e test when introducing a new model or environment in RLinf. Use when adding a new embodied model (e.g. dexbotic), new env (e.g. maniskill_libero), or new model+env combination that should be installable, dockerized, and tested in CI.
devcontainer-management
netalertx
Guide for identifying, managing, and running commands within the NetAlertX development container. Use this when asked to run commands, testing, setup scripts, or troubleshoot container issues.