Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
laurigates avatar

Python Containers

  • 68 installs
  • 49 repo stars
  • Updated August 4, 2026
  • laurigates/claude-plugins

Helps with python tasks.

About

python-containers is a Claude Code skill for python. It helps solo builders move faster with AI-assisted development.

  • python-containers
  • Python
  • AI-coding skill

Python Containers by the numbers

  • 68 all-time installs (skills.sh)
  • +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #124 of 290 Python skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/laurigates/claude-plugins --skill python-containers

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs68
repo stars49
Last updatedAugust 4, 2026
Repositorylaurigates/claude-plugins

What it does

Helps with python tasks.

Files

SKILL.mdMarkdownGitHub ↗

Python Container Optimization

Expert knowledge for building optimized Python container images using slim base images, virtual environments, modern package managers (uv, poetry), and multi-stage build patterns.

When to Use This Skill

Use this skill when...Use container-development instead when...
Building Python-specific DockerfilesGeneral multi-stage build patterns
Optimizing Python image sizesLanguage-agnostic container security
Handling pip/poetry/uv in containersDocker Compose configuration
Dealing with musl/glibc issuesNon-Python container optimization

Core Expertise

Python Container Challenges:

  • Large base images with unnecessary packages (~1GB)
  • Critical: Alpine causes issues with Python (musl vs glibc)
  • Complex dependency management (pip, poetry, pipenv, uv)
  • Compiled C extensions requiring build tools
  • Virtual environment handling in containers

Key Capabilities:

  • Slim-based images (NOT Alpine for Python)
  • Multi-stage builds with modern tools (uv recommended)
  • Virtual environment optimization
  • Compiled extension handling
  • Non-root user configuration

Why NOT Alpine for Python

Use slim instead of Alpine for Python containers. Alpine uses musl libc which causes:

  • Many wheels don't work (numpy, pandas, scipy)
  • Forces compilation from source (slow builds)
  • Larger final images due to build tools
  • Runtime errors with native extensions

Optimized Dockerfile Pattern (uv)

The recommended pattern achieves ~80-120MB images:

# Build stage
FROM python:3.11-slim AS builder
WORKDIR /app

RUN pip install --no-cache-dir uv

# Copy dependency files
COPY pyproject.toml uv.lock ./

# Install dependencies with uv (much faster than pip)
RUN uv sync --frozen --no-dev

COPY . .

# Runtime stage
FROM python:3.11-slim
WORKDIR /app

# Install only runtime dependencies (if needed)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    libpq5 \
    && rm -rf /var/lib/apt/lists/*

# Create non-root user
RUN addgroup --gid 1001 appgroup && \
    adduser --uid 1001 --gid 1001 --disabled-password appuser

# Copy only what's needed
COPY --from=builder --chown=appuser:appgroup /app/.venv /app/.venv
COPY --chown=appuser:appgroup app/ /app/app/
COPY --chown=appuser:appgroup pyproject.toml /app/

ENV PATH="/app/.venv/bin:$PATH" \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1

USER appuser
EXPOSE 8000

HEALTHCHECK --interval=30s CMD python -c "import requests; requests.get('http://localhost:8000/health')" || exit 1

CMD ["python", "-m", "app"]

Package Manager Summary

ManagerSpeedCommandNotes
uv10-100x fasteruv sync --frozen --no-devRecommended
poetryStandardpoetry install --only=mainSet POETRY_VIRTUALENVS_IN_PROJECT=1
pipStandardpip install --no-cache-dir --prefix=/install -r requirements.txtUse --prefix for multi-stage

Performance Impact

MetricFull (1GB)Slim (400MB)Multi-Stage (150MB)Optimized (100MB)
Image Size1GB400MB150MB100MB
Pull Time4m1m 30s35s20s
Build Time (pip)5m4m3m3m
Build Time (uv)--45s30s
Memory Usage600MB350MB200MB150MB

Security Impact

Image TypeVulnerabilitiesSizeRisk
python:3.11 (full)50-70 CVEs1GBHigh
python:3.11-slim12-18 CVEs400MBMedium
Multi-stage slim8-12 CVEs150MBLow
Distroless Python4-6 CVEs140MBVery Low

Agentic Optimizations

ContextCommandPurpose
Quick buildDOCKER_BUILDKIT=1 docker build -t app .Fast build with cache
Size checkdocker images app --format "table {{.Repository}}\t{{.Size}}"Check image size
Layer analysis`docker history app:latest --human \head -20`
Test importsdocker run --rm app python -c "import app"Verify imports work
Dependency listdocker run --rm app pip list --format=freezeSee installed packages
Security scandocker run --rm app pip-auditCheck for vulnerabilities

Best Practices

  • Use slim NOT alpine for Python
  • Use uv for fastest builds (10-100x faster than pip)
  • Use multi-stage builds
  • Set PYTHONUNBUFFERED=1 and PYTHONDONTWRITEBYTECODE=1
  • Run as non-root user
  • Use virtual environments and pin dependencies with lock files
  • Use --no-cache-dir with pip

For detailed examples, advanced patterns, and best practices, see REFERENCE.md.

Related Skills

  • container-development - General container patterns, multi-stage builds, security
  • go-containers - Go-specific container optimizations
  • nodejs-containers - Node.js-specific container optimizations

Related skills

Pythonbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.