File contents /docker - Dockerfile Generator
Generate optimized Dockerfiles with best practices.
Usage
/docker # Auto-detect and generate
/docker python # Python application
/docker rust # Rust application (multi-stage)
/docker --slim # Minimal image size
What This Skill Does
Detect Application Type - Language, framework, dependencies
Generate Dockerfile - Optimized for size and build speed
Add .dockerignore - Exclude unnecessary files
Multi-stage Builds - Separate build and runtime stages
Security Hardening - Non-root user, minimal base image
Templates
Python Application
# Build stage
FROM python:3.11-slim as builder
WORKDIR /app
RUN pip install --no-cache-dir build
COPY pyproject.toml .
COPY src/ src/
RUN python -m build --wheel
# Runtime stage
FROM python:3.11-slim
WORKDIR /app
RUN useradd --create-home --shell /bin/bash app
COPY --from=builder /app/dist/*.whl .
RUN pip install --no-cache-dir *.whl && rm *.whl
USER app
ENTRYPOINT ["python", "-m", "myapp"]
Rust Application
# Build stage
FROM rust:1.75-slim as builder
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY src/ src/
RUN cargo build --release
# Runtime stage
FROM debian:bookworm-slim
RUN useradd --create-home --shell /bin/bash app
COPY --from=builder /app/target/release/myapp /usr/local/bin/
USER app
ENTRYPOINT ["myapp"]
.dockerignore
.git/
.gitignore
.venv/
__pycache__/
*.pyc
target/
*.md
.github/
tests/
Dockerfile
.dockerignore
Best Practices Applied
Multi-stage builds - Smaller final image
Layer caching - Dependencies before source code
Non-root user - Security hardening
Slim base images - Minimal attack surface
.dockerignore - Faster builds, smaller context
No cache mounts - Reproducible builds
Pinned versions - Reproducible base images
Instructions for Claude
When /docker is invoked:
Detect project type - Check for pyproject.toml, Cargo.toml, etc.
Identify entry point - Main module or binary
Use multi-stage - Always separate build from runtime
Minimize layers - Combine RUN commands where sensible
Add .dockerignore - Create if missing
Security - Non-root user, minimal base image
Document - Add comments explaining non-obvious choices
1 --- 2 name: docker 3 description: Dockerfile Generator 4 --- 5 6 # /docker - Dockerfile Generator 7 8 Generate optimized Dockerfiles with best practices. 9 10 ## Usage 11 ``` 12 /docker # Auto-detect and generate 13 /docker python # Python application 14 /docker rust # Rust application (multi-stage) 15 /docker --slim # Minimal image size 16 ``` 17 18 ## What This Skill Does 19 20 1. **Detect Application Type** - Language, framework, dependencies 21 2. **Generate Dockerfile** - Optimized for size and build speed 22 3. **Add .dockerignore** - Exclude unnecessary files 23 4. **Multi-stage Builds** - Separate build and runtime stages 24 5. **Security Hardening** - Non-root user, minimal base image 25 26 ## Templates 27 28 ### Python Application 29 ```dockerfile 30 # Build stage 31 FROM python:3.11-slim as builder 32 33 WORKDIR /app 34 RUN pip install --no-cache-dir build 35 COPY pyproject.toml . 36 COPY src/ src/ 37 RUN python -m build --wheel 38 39 # Runtime stage 40 FROM python:3.11-slim 41 42 WORKDIR /app 43 RUN useradd --create-home --shell /bin/bash app 44 COPY --from=builder /app/dist/*.whl . 45 RUN pip install --no-cache-dir *.whl && rm *.whl 46 47 USER app 48 ENTRYPOINT ["python", "-m", "myapp"] 49 ``` 50 51 ### Rust Application 52 ```dockerfile 53 # Build stage 54 FROM rust:1.75-slim as builder 55 56 WORKDIR /app 57 COPY Cargo.toml Cargo.lock ./ 58 COPY src/ src/ 59 60 RUN cargo build --release 61 62 # Runtime stage 63 FROM debian:bookworm-slim 64 65 RUN useradd --create-home --shell /bin/bash app 66 COPY --from=builder /app/target/release/myapp /usr/local/bin/ 67 68 USER app 69 ENTRYPOINT ["myapp"] 70 ``` 71 72 ### .dockerignore 73 ``` 74 .git/ 75 .gitignore 76 .venv/ 77 __pycache__/ 78 *.pyc 79 target/ 80 *.md 81 .github/ 82 tests/ 83 Dockerfile 84 .dockerignore 85 ``` 86 87 ## Best Practices Applied 88 89 1. **Multi-stage builds** - Smaller final image 90 2. **Layer caching** - Dependencies before source code 91 3. **Non-root user** - Security hardening 92 4. **Slim base images** - Minimal attack surface 93 5. **.dockerignore** - Faster builds, smaller context 94 6. **No cache mounts** - Reproducible builds 95 7. **Pinned versions** - Reproducible base images 96 97 ## Instructions for Claude 98 99 When /docker is invoked: 100 101 1. **Detect project type** - Check for pyproject.toml, Cargo.toml, etc. 102 2. **Identify entry point** - Main module or binary 103 3. **Use multi-stage** - Always separate build from runtime 104 4. **Minimize layers** - Combine RUN commands where sensible 105 5. **Add .dockerignore** - Create if missing 106 6. **Security** - Non-root user, minimal base image 107 7. **Document** - Add comments explaining non-obvious choices
AreteDriver/ai-skills/tree/main/personas/devops/docker commit 196e93b8a1
Frequently asked questions How do I install the Docker skill? Run npx skillmds@latest add aretedriver/docker in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Docker skill do? Dockerfile Generator It is listed under DevOps & Infra on SkillMD.
Is Docker safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Docker? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Docker free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Docker? AreteDriver (@aretedriver) published this skill. Their other Agent Skills are listed on their SkillMD profile.