DO

docker-container-standards

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.zip

Installs 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.
179 charsno explicit “when” trigger
Intermediate

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

You give it
Dockerfile or containerization task
You get back
secure and optimized Docker container configuration

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 using USER.
  • Minimal Base Images: Use small, secure base images (e.g., python:3.12-slim or node:20-alpine / distroless).
  • No Secrets: Never hardcode secrets in Dockerfiles. Use environment variables.

2. Reliability & Health

  • HEALTHCHECK: Always define a HEALTHCHECK instruction using curl/wget or custom health probe.
  • Signal Handling: Use exec form for CMD (e.g. CMD ["python", "app.py"] instead of shell form CMD python app.py) to pass signals (like SIGTERM) 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 USERRUN useradd appuser && USER appuser
CMD python app.py (shell form)CMD ["python", "app.py"] (exec form)
Missing HEALTHCHECKAdd explicit HEALTHCHECK statement
Copying code before dependency installCopy lockfiles, run install, then copy source code
Including .git or .env in final imageDefine .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.

SkillInstallsUpdatedSafetyDifficulty
docker-container-standards (this skill)01moCautionIntermediate
docker-expert116moReviewIntermediate
deployment-engineer43moNo flagsAdvanced
devops26moReviewIntermediate

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.

1135

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.

418

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.

216

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.

215

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.

16

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.

13

Search skills

Search the agent skills registry