docker

Build multi-arch Docker images with BuildKit and push to ghcr.io.

1|Updated Mar 18, 2024
One-click install
npx skills add https://github.com/erfianugrah/dotfiles --skill docker-erfianugrah
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docker
Source: https://github.com/erfianugrah/dotfiles/tree/main/.pi/agent/skills/docker
Command: npx skills add https://github.com/erfianugrah/dotfiles --skill docker-erfianugrah

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of slow, opaque, and error-prone Docker image builds and deployments by giving you a repeatable way to author Dockerfiles, build multi-arch images, and verify what you actually shipped.

Core Features & Use Cases

  • Dockerfile authoring with BuildKit: Enables efficient layer ordering, cache mounts, secrets, and SSH forwarding to build images faster and more securely.
  • buildx multi-arch builds + registry workflows: Supports building for multiple platforms and pushing to registries like ghcr.io with cache-to/cache-from.
  • Image + container inspection for debugging: Provides commands to inspect layer history, manifests, config, logs, exec sessions, network/process state, and forensic snapshots.
  • Production-aware workflow discipline: Encourages immutable tag practices (for Compose) while keeping optional rolling tags for human convenience.

Use case example: You need to ship a multi-arch release of a service to ghcr.io while keeping builds fast—this skill guides you to structure the Dockerfile for cache reuse, build with buildx using registry cache, push properly tagged images, and then inspect layers/manifests if runtime behavior differs from expectations.

Quick Start

Ask the AI to help you write an optimized multi-stage Dockerfile using BuildKit cache mounts and secrets, then generate the exact buildx commands to build for linux/amd64 and linux/arm64 and push to ghcr.io with buildcache.

Frequently Asked Questions about docker

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build multi-arch Docker images and push them to ghcr.io?

To build multi-arch Docker images and push to ghcr.io, use buildx with cache-to and cache-from flags for registry caching. This ensures reliable cross-platform builds while maintaining fast build speeds through BuildKit layer caching.

What is the best way to debug a Docker image that behaves differently than expected?

The best way to debug a Docker image is by inspecting its layer history, manifests, and configuration. You can use commands like image history, imagetools inspect, container logs, and exec inspection to investigate runtime failures and verify shipped contents.

How do I use BuildKit secrets and SSH mounts when building a Dockerfile?

BuildKit secrets and SSH mounts are used during Dockerfile builds by configuring cache mounts and SSH forwarding. This approach allows secure secret management during the build process without leaking sensitive data into the final image layers.

Can I use buildx to load images locally instead of pushing them to a registry?

Yes, you can use buildx to load images locally by applying the correct buildx flags for load versus push. This distinction allows you to test images locally before pushing them to registries like ghcr.io for deployment.

Why should I use immutable tags for Docker Compose deployments?

Immutable tags should be used for Docker Compose deployments to ensure production-aware workflow discipline. This practice prevents accidental rollbacks or inconsistent environments while keeping optional rolling tags available for human convenience.

How do I optimize Docker layer ordering for faster build speeds?

To optimize Docker layer ordering for faster build speeds, structure your Dockerfile to maximize cache reuse. Deterministic layer ordering combined with BuildKit cache mounts ensures efficient builds and reduces redundant processing during image creation.