ardurai/god-skill-suite/god-containers-advanced

Claude Code and agent skill by ardurai/god-skill-suite

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

God-level container engineering skill going far beyond basic Docker. Covers OCI specification (image spec, runtime spec, distribution spec), Docker internals (layers, union filesystems, copy-on-write), BuildKit (cache mounts, secret mounts, SSH mounts, multi-platform builds), rootless containers, container runtime alternatives (containerd, CRI-O, gVisor, Kata Containers), image optimization (multi-stage, distroless, scratch base), container security (seccomp, AppArmor, capabilities, rootless, image signing with cosign), Docker Compose for local development, and the truth that a container is just a process with namespaces and cgroups — understanding Linux is understanding containers.

Install

npx vskill@latest install ardurai/god-skill-suite/god-containers-advanced

SKILL.md

The same SKILL.md was published earlier as ardurai/god-skill-suite/god-containers-advanced.

god-containers-advanced — Deep Container Engineering Skill

Personality & Operating Principles

You are a container platform engineer who has debugged layer cache misses at 3am, written custom seccomp profiles for hardened workloads, and optimized images from 2GB to 8MB. You understand containers at the Linux kernel level — namespaces, cgroups, OverlayFS — not just as Docker abstractions. You care about build reproducibility, supply chain security, and runtime isolation.

Anti-hallucination rules:

  • Never invent BuildKit syntax. The --mount=type=cache, --mount=type=secret, and --mount=type=ssh syntax is verified; always recommend checking current Dockerfile reference at docs.docker.com/engine/reference/builder.
  • Distroless image names (e.g., gcr.io/distroless/static-debian12) change with releases — instruct users to check the current Chainguard/Google Distroless GitHub repo.
  • gVisor (runsc) and Kata Containers support vary by Kubernetes distribution and version. Flag when recommending them.
  • Don't invent OCI specification version numbers — reference the opencontainers.org specs.
  • seccomp profile syscall lists differ by Docker version. Direct users to the official Docker seccomp default profile on GitHub.

1. The Foundational Truth

A container is a process. Not a VM, not a mini-OS. A process with:

  • Namespaces for isolation (PID, network, mount, UTS, IPC, user)
  • Cgroups for resource limits (CPU, memory, I/O)
  • OverlayFS (or another union filesystem) for the layered filesystem view
  • Capabilities dropped to minimize privilege
  • Seccomp to restrict syscall surface

Prove it: docker run -d nginx → ps aux | grep nginx → you'll see nginx processes directly in the host process list with different PIDs than inside the container. cat /proc/<nginx_pid>/cgroup shows the Docker cgroup hierarchy.


2. OCI Specifications

The Open Container Initiative (OCI) defines standards that all compliant runtimes and tools share. Docker, containerd, Podman, CRI-O all implement these.

Image Specification

An OCI image consists of:

  • Manifest: JSON document listing config blob + layer blobs by digest (sha256)
  • Config: JSON with entrypoint, env vars, working dir, exposed ports, labels, history
  • Layers: Ordered sequence of tar archives (each = filesystem diff). Applied bottom-up.
  • Index (Image Index): Manifest of manifests for multi-architecture images — each platform entry points to its own manifest
json
// Simplified manifest structure
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"digest": "sha256:abc123...",
"size": 1234
},
"layers": [
{
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
"digest": "sha256:def456...",
"size": 12345678
}
]
}
Runtime Specification

The OCI runtime spec defines config.json — the bundle a runtime (runC) receives:

  • root.path: rootfs directory
  • process: args, env, cwd, capabilities, rlimits, seccomp
  • mounts: additional bind mounts
  • linux.namespaces: which namespaces to create
  • linux.cgroupsPath: cgroup path
  • linux.seccomp: syscall filter profile
Distribution Specification

Defines the HTTP API for push/pull from registries:

  • GET /v2/<name>/manifests/<reference> — pull manifest
  • PUT /v2/<name>/manifests/<reference> — push manifest
  • POST /v2/<name>/blobs/uploads/ — initiate blob upload

Why care?: Understanding this lets you interact with registries directly via curl, implement custom registry middleware, or debug push/pull failures.


3. Union Filesystems — OverlayFS

OverlayFS presents a merged view of multiple directories:

upperdir = read-write layer (container's writable layer)
lowerdir = read-only layers (image layers, bottom to top)
workdir = internal temp dir (same filesystem as upperdir)
merged = union view presented to the container

Copy-on-write semantics:

  1. Container reads a file → served from lowerdir directly (no copy)
  2. Container writes a file that exists in lowerdir → kernel copies file to upperdir, then writes there
  3. Container deletes a file from lowerdir → creates a "whiteout" file in upperdir (special char device)
  4. Container creates new file → goes directly to upperdir

Layer ordering for cache efficiency — critical for build performance:

dockerfile
# BAD: source code (frequently changes) before dependencies (rarely changes)
COPY . /app
RUN pip install -r requirements.txt
# GOOD: dependencies first (cache survives code changes)
COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY . /app

Inspect actual overlay mounts:

bash
# Find container's overlay mount
docker inspect <container> | jq '.[0].GraphDriver'
# Or directly
mount | grep overlay
cat /proc/mounts | grep overlay

4. BuildKit Deep Dive

BuildKit is the current default Docker build backend (enabled by default in Docker 23.0+). It provides parallelism, better caching, and advanced mount types.

Enable BuildKit (older Docker)
bash
export DOCKER_BUILDKIT=1
# Or in daemon.json:
{ "features": { "buildkit": true } }
Cache Mounts — Preserve Package Manager Caches
dockerfile
# syntax=docker/dockerfile:1
FROM python:3.12-slim AS builder
# Cache pip's download cache between builds
# The cache persists across builds on the same BuildKit daemon
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-cache-dir -r requirements.txt
# APT cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
build-essential
# Go module cache
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build ./...

`sharing` modes: shared (default, concurrent access), locked (exclusive), private (new cache per build).

Secret Mounts — Credentials During Build
dockerfile
# Secrets are NEVER written to the image layers
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc \
npm install
# SSH mounts for private Git repos
RUN --mount=type=ssh \
git clone git@github.com:myorg/private-repo.git
bash
# Pass secret at build time (from file)
docker buildx build --secret id=npmrc,src=$HOME/.npmrc .
# Pass secret from environment
echo "$NPM_TOKEN" | docker buildx build --secret id=npm_token,src=- .
# Enable SSH agent forwarding
docker buildx build --ssh default=$SSH_AUTH_SOCK .
BuildKit Cache Export/Import
bash
# Export cache to registry (for CI/CD sharing)
docker buildx build \
--cache-to type=registry,ref=myregistry.io/myapp:cache,mode=max \
--cache-from type=registry,ref=myregistry.io/myapp:cache \
.
# Local cache (for single-machine CI)
docker buildx build \
--cache-to type=local,dest=/tmp/buildcache,mode=max \
--cache-from type=local,src=/tmp/buildcache \
.
# Inline cache (embedded in image — simpler, less efficient)
docker buildx build \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from myregistry.io/myapp:latest \
.

5. Multi-Stage Builds

Multi-stage builds are the standard pattern for producing small production images:

dockerfile
# syntax=docker/dockerfile:1
# ─── Stage 1: Build ───────────────────────────────────────────
FROM golang:1.22-alpine AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /app ./cmd/server
# ─── Stage 2: Test (optional — run tests in CI) ───────────────
FROM builder AS test
RUN go test ./...
# ─── Stage 3: Production ──────────────────────────────────────
FROM gcr.io/distroless/static-debian12 AS production
COPY --from=builder /app /app
EXPOSE 8080
USER nonroot:nonroot
ENTRYPOINT ["/app"]
bash
# Build only production stage
docker buildx build --target production -t myapp:latest .
# Run tests in CI
docker buildx build --target test .

6. Image Optimization

Base Image Comparison
BaseSizeShellPackage MgrUse Case
ubuntu:24.04~80MBbashaptDebug, general
debian:slim~75MBbashaptGeneral apps
alpine:3.19~7MBashapkSmall images (musl libc — verify compat)
gcr.io/distroless/base~20MBNoneNoneJVM, Python, Node production
gcr.io/distroless/static~2MBNoneNoneStatically compiled Go/Rust
scratch0NoneNoneStatically linked binary only
cgr.dev/chainguard/static~2MBNoneNoneWolfi-based, daily updates

Distroless advantages: No shell means no shell injection. No package manager means no apt privilege escalation. Smaller attack surface = smaller CVE surface. Images are still OCI-compliant.

Alpine warning: musl libc behaves differently from glibc. Some C extensions, DNS behavior (musl has single-threaded DNS resolution by default), and stack sizes differ. Test thoroughly before adopting for critical workloads.

Layer Optimization Tricks
dockerfile
# Combine RUN commands to reduce layers
# BAD — 3 layers
RUN apt-get update
RUN apt-get install -y curl
RUN rm -rf /var/lib/apt/lists/*
# GOOD — 1 layer, no cache left in image
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*
# .dockerignore is as important as Dockerfile
# Prevents sending large contexts to BuildKit daemon
cat > .dockerignore <<'EOF'
.git
.github
**/*.test
**/*_test.go
node_modules
dist
*.log
.env*
EOF

7. Multi-Architecture Builds

bash
# Create a builder with multi-platform support
docker buildx create --name multiarch --driver docker-container --use
docker buildx inspect --bootstrap
# Build for multiple platforms using QEMU emulation
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-t myregistry.io/myapp:latest \
--push \
.
# In Dockerfile: use TARGETARCH build arg (set automatically by buildx)
FROM --platform=$BUILDPLATFORM golang:1.22 AS builder
ARG TARGETOS TARGETARCH
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /app .
FROM gcr.io/distroless/static-debian12
COPY --from=builder /app /app

Native builders: For better performance (especially ARM), use actual ARM hardware or cloud instances as buildx nodes instead of QEMU emulation:

bash
docker buildx create --name multiarch \
--platform linux/amd64 \
--append ssh://user@arm-host

8. Rootless Containers

Running Docker/Podman without root privileges uses user namespace mapping: the root user inside the container (UID 0) maps to an unprivileged host user (e.g., UID 100000).

bash
# Podman is rootless by default
podman run --rm -it alpine sh
# Docker rootless mode (experimental/production)
dockerd-rootless-setuptool.sh install
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock
docker run --rm -it alpine sh
# Check user mapping
cat /proc/self/uid_map # Inside container vs host

Limitations of rootless:

  • Cannot bind ports < 1024 (requires net.ipv4.ip_unprivileged_port_start=0 sysctl or use a reverse proxy)
  • OverlayFS may not be available without kernel 5.11+ or fuse-overlayfs fallback
  • Network performance slightly lower (slirp4netns vs native networking)
  • Cannot set cgroup limits without cgroup v2 + systemd delegation

9. Container Runtime Landscape

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 98 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ardurai/god-skill-suite/god-containers-advanced/badge)](https://verified-skill.com/skills/ardurai/god-skill-suite/god-containers-advanced)

Something wrong with this skill or its page? Tell us.