dockerfile-python-app

A guide to writing a Dockerfile for a Python application. A Dockerfile is a recipe for building a container image with the application, its dependencies, and its runtime settings.

In plain words
What is it for?
Use it to arrange build steps for caching, install Python dependencies, create a non-root runtime user, expose a service port, add health checks, and separate build and runtime images.
Why use it?
It helps keep the image smaller and rebuilds faster while reducing security risks from running as an administrator or copying secrets into the image.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/vikasudasi/skill-vault/dockerfile-python-app
Any agent
npx skills add vikasudasi/skill-vault --skill dockerfile-python-app
Clone the repo
git clone --depth 1 https://github.com/vikasudasi/skill-vault

Made for: Claude Code, Codex.

Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 487 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.00487
Opus 5 $0.00015 $0.00244
Sonnet 5 $0.00006 $0.00097
Haiku 4.5 $0.00003 $0.00049

Measured yesterday against content hash a76223857467, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

dockerfile-python-app scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skill_vault/data/skills/dockerfile-python-app/SKILL.md · 69 lines

What it actually says

Dockerfile for a Python App

Use when containerizing a Python service with a small, cache-friendly, secure image.

Efficient + secure Dockerfile

FROM python:3.12-slim

ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

WORKDIR /app

# Install deps first so layer cache survives code changes
COPY pyproject.toml .
RUN pip install --no-cache-dir .

# Add code last
COPY . .

# Run as non-root
RUN useradd --create-home appuser
USER appuser

EXPOSE 8080
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]

Build-time tips (T3-style — each RUN is a layer)

  • COPY only what a step needs, after install → code changes don't rebuild deps.
  • Combine RUN commands with && and clean caches in the same layer.
  • Use --no-cache-dir to keep images slim.

Security

  • Default to a non-root user — never run the app as root in the image.
  • Pin base image tags; prefer -slim over full to shrink attack surface.
  • Don't COPY secrets; inject at runtime via env/secrets.

Multi-stage (build vs runtime)

Keep the builder and runtime separate when you compile assets or build wheels:

FROM python:3.12 AS builder
# ...build...
FROM python:3.12-slim AS runtime
COPY --from=builder /app /app

Pitfalls

  • .dockerignore matters — it also stops git metadata from breaking builds.
  • Streaming logs need PYTHONUNBUFFERED=1, or uvicorn output buffers.
Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 69 lines · 31 tokens per session scan A a76223857467

Subscribe to this mod's changes

dockerfile-python-app is a skill published in the GitHub repository vikasudasi/skill-vault (0 stars, last pushed 16d ago), licensed Apache-2.0. It adds 31 tokens to every session and 487 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

Cloud Security & Container Hardening

AWS/Azure/GCP security auditing, container and Kubernetes hardening, Infrastructure as Code scanning, and cloud compliance assessment.

Masriyan/Claude-Code-CyberSecurity-Skill · 30 tokens

container-manager-kubernetes-operations

Full operational Kubernetes surface via the container-manager-mcp MCP server — workloads (pods/rollouts/StatefulSets/DaemonSets/ReplicaSets/Jobs/CronJobs), config (ConfigMaps/Secrets/Namespaces/CRDs/patch), networking (Ingress/native Services/NetworkPolicy/DNS), storage (PV/PVC/StorageClass/snapshots/CSI), RBAC…

Knuckles-Team/container-manager-mcp · 189 tokens

container-manager-config-walkthrough

End-user setup guide for the container-manager-mcp MCP server — choosing CONTAINERMANAGERTYPE (docker/podman/kubernetes/multi), wiring .env / mcpconfig toggles, connecting remote Docker/Podman hosts via the tunnel-manager inventory versus remote Kubernetes clusters via kubeconfig contexts, and a first-run verification…

Knuckles-Team/container-manager-mcp · 119 tokens

container-manager-kg-ingestion

Snapshot a host's Docker/Podman/Swarm inventory into the epistemic-graph knowledge graph as typed OWL nodes via the container-manager-mcp MCP server — containers, images, volumes, networks, swarm services and nodes, with their :usesImage / :runsOn / :builtFrom links. Use when the agent must record live container state…

Knuckles-Team/container-manager-mcp · 116 tokens

container-manager-multi-context

Operate several container backends and contexts at once — Kubernetes, Docker, Podman, and Swarm — via the container-manager-mcp MCP server's cmmulticontext tool, with per-call backend/context selection and parallel fan-out across a configured pool of contexts. Use when the agent must compare, migrate between, or…

Knuckles-Team/container-manager-mcp · 118 tokens

container-manager-podman-operations

Rootless Podman pod/kube operations via the container-manager-mcp MCP server — pods (create/list/stats/top/inspect/logs/stop/rm), Kubernetes YAML interop (generate/play kube), checkpoint/restore, pod-scoped networks and volumes, health checks, and system prune. Use when the agent must drive Podman pod-level workloads…

Knuckles-Team/container-manager-mcp · 114 tokens