Agent skill
docker-hub-toolkit
Automate Python project Docker Hub deployments with optimized multi-stage builds, CI/CD pipelines, and security best practices. This skill should be used when users ask to containerize Python apps, build Docker images, push to Docker Hub, set up CI/CD for Docker, optimize Dockerfiles, debug Docker build failures, or deploy Python projects as containers.
Install this agent skill to your Project
npx add-skill https://github.com/alijilani-dev/Claude/tree/main/skills/docker-hub-toolkit
SKILL.md
Docker Hub Toolkit
End-to-end automation for deploying Python project images to Docker Hub with maximum performance and efficiency.
What This Skill Does
- Generates optimized multi-stage Dockerfiles (base → builder → dev → production)
- Builds, tags, and pushes images to Docker Hub
- Creates CI/CD pipelines (GitHub Actions) for automated deployment
- Optimizes image size and build speed with BuildKit caching
- Sets up multi-platform builds (amd64/arm64)
- Generates
.dockerignoreanddocker-compose.yml - Scans images for security vulnerabilities
- Debugs failed Docker builds
What This Skill Does NOT Do
- Deploy to Kubernetes/ECS/cloud orchestrators (container runtime only)
- Manage Docker Hub billing or account settings
- Handle non-Python project images
- Create Docker Swarm or cluster configurations
- Manage Docker Hub webhooks or automated test integrations
Before Implementation
Gather context to ensure successful implementation:
| Source | Gather |
|---|---|
| Codebase | Python framework (FastAPI/Flask/Django), entry point, dependencies file |
| Conversation | Docker Hub username, image name, target platforms, version tag |
| Skill References | Multi-stage patterns, CI/CD templates, security practices from references/ |
| User Guidelines | Team Docker standards, naming conventions, security requirements |
Ensure all required context is gathered before implementing. Only ask user for THEIR specific requirements (domain expertise is in this skill).
Required Clarifications
Ask about USER'S context:
- Docker Hub credentials: "What is your Docker Hub username/namespace?"
- Project type: "What Python framework? (FastAPI, Flask, Django, script)"
- Entry point: "What command starts your app? (e.g.,
uvicorn app.main:app)" - Deployment target: "Local push, or automated CI/CD via GitHub Actions?"
Workflow
Full Deployment Pipeline
1. Generate Dockerfile → Multi-stage optimized build
2. Create .dockerignore → Exclude unnecessary files
3. Build image → With BuildKit caching
4. Tag image → Semantic version + git SHA
5. Security scan → Check for vulnerabilities
6. Push to Docker Hub → Authenticated push
7. Set up CI/CD → GitHub Actions automation (optional)
Stage-by-Stage Execution
Stage 1: Generate Base Configuration
- Detect Python version from
pyproject.toml,setup.py, or.python-version - Identify dependency file (
requirements.txt,pyproject.toml,Pipfile) - Generate
.dockerignorefromassets/templates/dockerignore.template - Create multi-stage Dockerfile using patterns from
references/multi-stage-builds.md
Stage 2: Build Dependencies Stage
- Use
--mount=type=cache,target=/root/.cache/pipfor pip caching - Use
--mount=type=bindfor dependency files - Install to
--userfor clean multi-stage copy - Verify dependency resolution succeeds
Stage 3: Development/Test Stage (Optional)
- Copy dependencies from builder
- Copy source code
- Run tests (
pytest) and linting - Target with
docker build --target dev
Stage 4: Production Build & Push
- Fresh slim base image
- Create non-root user
- Copy only runtime dependencies from builder
- Set proper
CMD/ENTRYPOINT - Tag with version strategy
- Push to Docker Hub
Available Scripts
| Script | Purpose | Usage |
|---|---|---|
scripts/build-and-push.sh |
Build, tag, and push image | bash scripts/build-and-push.sh USERNAME APP_NAME VERSION |
scripts/validate-dockerfile.sh |
Lint and validate Dockerfile | bash scripts/validate-dockerfile.sh [path/to/Dockerfile] |
scripts/setup-multiplatform.sh |
Configure buildx for multi-arch | bash scripts/setup-multiplatform.sh |
Dependencies
- Docker Engine 20.10+ (BuildKit support)
- Docker CLI with buildx plugin
- Docker Hub account with access token
- Git (for SHA-based tagging)
- Python 3.10+ (for the project being containerized)
Error Handling
| Error | Recovery |
|---|---|
| Build fails on pip install | Check requirements.txt syntax, verify package availability |
| Push denied/unauthorized | Run docker login, verify access token |
| Image too large (>500MB) | Switch to slim base, verify multi-stage COPY |
| BuildKit not available | Set DOCKER_BUILDKIT=1 or use docker buildx build |
| Multi-platform fails | Run scripts/setup-multiplatform.sh |
| Rate limit exceeded | Wait or use authenticated pulls |
See references/troubleshooting.md for comprehensive error resolution.
Input/Output
- Input: Python project with dependency file (requirements.txt/pyproject.toml)
- Output: Optimized Docker image pushed to Docker Hub at
username/app:tag
Output Checklist
Before delivering, verify:
- Multi-stage Dockerfile with base → builder → production stages
-
.dockerignoreexcludes.git,__pycache__,.venv,.env,node_modules - BuildKit cache mounts used for pip installs
- Non-root user in production stage
-
PYTHONDONTWRITEBYTECODE=1andPYTHONUNBUFFERED=1set - Image tagged with semantic version
- Image pushed successfully to Docker Hub
- Image size < 200MB (for typical Python apps)
- No secrets or credentials in image layers
- CI/CD pipeline configured (if requested)
Reference Files
| File | When to Read |
|---|---|
references/multi-stage-builds.md |
Dockerfile patterns, stage architecture, anti-patterns |
references/docker-hub-deployment.md |
Push workflow, tagging strategy, Hub settings |
references/ci-cd-github-actions.md |
GitHub Actions pipeline, caching, automation |
references/claude-integration.md |
Claude Code commands, hooks, CLAUDE.md standards |
references/troubleshooting.md |
Build/push errors, size issues, security fixes |
documentation/docker_hub_stages.md |
Original multi-stage build stages reference |
documentation/docker_hub_python_project_partner.md |
Claude capabilities for Docker Hub |
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
docker-rocker
Production-grade Docker containerization for FastAPI, Pytest, SQLModel, and Pydantic projects. This skill should be used when users ask to dockerize FastAPI applications, create multi-stage Docker builds, optimize Docker images for Python APIs, set up CI/CD Docker pipelines, or deploy containerized Python web APIs with maximum performance and minimal image size.
fastapi-helper
FastAPI development assistant for building modern Python web APIs. Provides guidance on routing, request/response handling, dependency injection, authentication, middleware, WebSockets, testing, and Pydantic models. Use when: (1) Creating FastAPI applications or endpoints, (2) Implementing CRUD operations, (3) Setting up authentication/authorization, (4) Working with request parameters (path, query, body, headers, cookies, forms, files), (5) Configuring middleware or CORS, (6) Implementing WebSocket connections, (7) Writing tests for FastAPI apps, (8) Defining Pydantic models for validation.
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.
internal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).
cover-letter-generator
Generate tailored AI-focused cover letters using the PSI (Problem-Solution-Impact) methodology. Use when: (1) User wants to create cover letters for AI/ML job applications, (2) User provides a resume and wants LinkedIn job matching, (3) User asks for personalized cover letters based on job postings, (4) User mentions applying for AI Engineer, ML Engineer, or similar technical roles. Integrates market intelligence, LinkedIn research via Playwright, and professional writing standards.
skill-validator
Validates skills against production-level criteria with 9-category scoring. This skill should be used when reviewing, auditing, or improving skills to ensure quality standards. Evaluates structure, content, user interaction, documentation, domain standards, technical robustness, maintainability, zero-shot implementation, and reusability. Returns actionable validation report with scores and improvement recommendations.
Didn't find tool you were looking for?