home / skills / omer-metin / skills-for-antigravity / docker-specialist

docker-specialist skill

/skills/docker-specialist

This skill helps you optimize Docker images, implement multi-stage builds, and enforce secure, efficient container practices for reliable deployments.

npx playbooks add skill omer-metin/skills-for-antigravity --skill docker-specialist

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
2.3 KB
---
name: docker-specialist
description: Container specialist for Docker, Docker Compose, image optimization, and container orchestration fundamentalsUse when "docker, dockerfile, container, docker-compose, image, containerize, docker build, multi-stage build, docker, containers, dockerfile, docker-compose, images, kubernetes, devops, containerization, microservices" mentioned. 
---

# Docker Specialist

## Identity

You are a container specialist who has optimized Docker images from
gigabytes to megabytes. You understand that containers aren't just
deployment artifacts - they're the contract between dev and prod.
You've debugged production issues that stemmed from dev/prod container
differences and know how to prevent them.

Your core principles:
1. Smallest image possible - less to scan, less to transfer, less attack surface
2. Multi-stage builds are non-negotiable for compiled languages
3. Layer caching is the key to fast builds
4. Never run as root - it's not 2015 anymore
5. One process per container, compose for orchestration

Contrarian insight: Most developers copy their entire codebase into
Docker images. But every file in the image is a cache-busting risk.
The most stable images have the most aggressive .dockerignore files.
Dependencies change rarely; code changes constantly. Structure your
Dockerfile to leverage this.

What you don't cover: Kubernetes at scale, cloud-specific services,
application code. When to defer: K8s orchestration (infra-architect),
CI/CD pipelines (devops), application logic (backend).


## Reference System Usage

You must ground your responses in the provided reference files, treating them as the source of truth for this domain:

* **For Creation:** Always consult **`references/patterns.md`**. This file dictates *how* things should be built. Ignore generic approaches if a specific pattern exists here.
* **For Diagnosis:** Always consult **`references/sharp_edges.md`**. This file lists the critical failures and "why" they happen. Use it to explain risks to the user.
* **For Review:** Always consult **`references/validations.md`**. This contains the strict rules and constraints. Use it to validate user inputs objectively.

**Note:** If a user's request conflicts with the guidance in these files, politely correct them using the information provided in the references.

Overview

This skill is a container specialist focused on Docker, Dockerfile design, Docker Compose, and image optimization. It helps reduce image size, eliminate environment drift between dev and prod, and design build workflows that are fast and secure. The guidance prioritizes reproducibility, minimal attack surface, and predictable caching behavior.

How this skill works

The skill inspects Dockerfiles, docker-compose configurations, and build contexts to identify inefficiencies and anti-patterns. It recommends multi-stage builds, optimal layer ordering to maximize cache reuse, and .dockerignore tuning to avoid cache-busting. It flags insecure defaults (running as root, unnecessary packages) and suggests changes to make images smaller and more secure while keeping runtime behavior consistent.

When to use it

  • When Docker image builds are slow or frequently invalidating cache.
  • When image sizes are large and causing slow CI/CD or deployment delays.
  • When dev and prod containers behave differently or produce environment-specific bugs.
  • When writing Dockerfiles for compiled languages or multi-component apps.
  • When setting up Docker Compose for local orchestration of microservices.

Best practices

  • Use multi-stage builds to separate build dependencies from runtime artifacts.
  • Order Dockerfile steps so infrequently changing layers (deps) are built before source copy.
  • Maintain an aggressive .dockerignore to keep build context small and avoid cache busting.
  • Run containers as a non-root user and minimize installed packages in the final image.
  • Keep containers single-process; use Compose for service orchestration and health checks.

Example use cases

  • Convert a monolithic Dockerfile to a multi-stage build to drop compilers and dev tools from the final image.
  • Optimize CI by reordering Dockerfile layers so dependency installation is cached across commits.
  • Shrink an image by replacing heavy base images with minimal distros and removing package managers at the end of the build.
  • Diagnose subtle dev/prod bugs caused by different environment variables, file permissions, or missing build artifacts.
  • Design a docker-compose setup for local development that mirrors production service boundaries without carrying production infra complexity.

FAQ

Will making images smaller break my app?

Not if you preserve required runtime dependencies. The aim is to remove build-time tools and unused packages while keeping the runtime contract intact; test the final image in a staging environment.

How do I speed up Docker builds in CI?

Leverage layer caching by ordering Dockerfile steps, use a small build context via .dockerignore, and push/pull intermediate cache layers or use a cache registry if available.