| name | docker |
| description | Dockerfile Generator |
| lifecycle | experimental |
/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