Skip to content
docker-hub-toolkit logo

Docker Hub Toolkit

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 Docke...

SKILL.md

Full skill instructions

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 .dockerignore and docker-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:

SourceGather
CodebasePython framework (FastAPI/​Flask/​Django), entry point, dependencies file
ConversationDocker Hub username, image name, target platforms, version tag
Skill ReferencesMulti-stage patterns, CI/​CD templates, security practices from references/
User GuidelinesTeam 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:

  1. Docker Hub credentials: "What is your Docker Hub username/​namespace?"
  2. Project type: "What Python framework? (FastAPI, Flask, Django, script)"
  3. Entry point: "What command starts your app? (e.g., uvicorn app.main:app)"
  4. 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
  1. Detect Python version from pyproject.toml, setup.py, or .python-version
  2. Identify dependency file (requirements.txt, pyproject.toml, Pipfile)
  3. Generate .dockerignore from assets/​templates/​dockerignore.template
  4. Create multi-stage Dockerfile using patterns from references/​multi-stage-builds.md
Stage 2: Build Dependencies Stage
  1. Use --mount=type=cache,target=/​root/​.cache/​pip for pip caching
  2. Use --mount=type=bind for dependency files
  3. Install to --user for clean multi-stage copy
  4. Verify dependency resolution succeeds
Stage 3: Development/​Test Stage (Optional)
  1. Copy dependencies from builder
  2. Copy source code
  3. Run tests (pytest) and linting
  4. Target with docker build --target dev
Stage 4: Production Build & Push
  1. Fresh slim base image
  2. Create non-root user
  3. Copy only runtime dependencies from builder
  4. Set proper CMD/ENTRYPOINT
  5. Tag with version strategy
  6. Push to Docker Hub

Available Scripts

ScriptPurposeUsage
scripts/​build-and-push.shBuild, tag, and push imagebash scripts/​build-and-push.sh USERNAME APP_NAME VERSION
scripts/​validate-dockerfile.shLint and validate Dockerfilebash scripts/​validate-dockerfile.sh [path/​to/​Dockerfile]
scripts/​setup-multiplatform.shConfigure buildx for multi-archbash 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

ErrorRecovery
Build fails on pip installCheck requirements.txt syntax, verify package availability
Push denied/​unauthorizedRun docker login, verify access token
Image too large (>500MB)Switch to slim base, verify multi-stage COPY
BuildKit not availableSet DOCKER_BUILDKIT=1 or use docker buildx build
Multi-platform failsRun scripts/​setup-multiplatform.sh
Rate limit exceededWait 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
  • .dockerignore excludes .git, __pycache__, .venv, .env, node_modules
  • BuildKit cache mounts used for pip installs
  • Non-root user in production stage
  • PYTHONDONTWRITEBYTECODE=1 and PYTHONUNBUFFERED=1 set
  • 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

FileWhen to Read
references/​multi-stage-builds.mdDockerfile patterns, stage architecture, anti-patterns
references/​docker-hub-deployment.mdPush workflow, tagging strategy, Hub settings
references/​ci-cd-github-actions.mdGitHub Actions pipeline, caching, automation
references/​claude-integration.mdClaude Code commands, hooks, CLAUDE.md standards
references/​troubleshooting.mdBuild/​push errors, size issues, security fixes
documentation/​docker_hub_stages.mdOriginal multi-stage build stages reference
documentation/​docker_hub_python_project_partner.mdClaude capabilities for Docker Hub

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View