xiaohongshu
xiaohongshu
This skill provides guidance for efficiently building, testing, and working with Docker images in this repository.
Full skill instructions
This skill provides guidance for efficiently building, testing, and working with Docker images in this repository.
scripts/build-local.sh [target]
gh authscripts/test-dockerfile.sh [target|dockerfile] [--cleanup]
build-local.shensure_base_image() checks timestamps),
but always rebuilds cookbook--cleanup to remove)scripts/shell.sh [target|cookbook] [tag]
The ensure_base_image() function (used for cookbook testing):
agentic-container:latest exists# Step 1: Initial build and test (will rebuild)
./scripts/test-dockerfile.sh standard
# Step 2: Iterate on goss tests WITHOUT rebuilding
# Edit goss/standard.yaml, then:
docker run --rm --user root \
-v "$PWD/goss/base-common.yaml:/tmp/goss-base-common.yaml:ro" \
-v "$PWD/goss/standard.yaml:/tmp/goss-base.yaml:ro" \
test-standard:latest \
bash -c 'goss -g /tmp/goss-base-common.yaml -g /tmp/goss-base.yaml validate --format documentation'
# Step 3: Final test with script (rebuilds to verify)
./scripts/test-dockerfile.sh standard --cleanup
# Check what images exist
docker images | grep -E '(agentic|test-)'
# If test-standard:latest exists, use it directly
docker run --rm test-standard:latest python --version
# Only rebuild if you changed the Dockerfile
./scripts/build-local.sh standard agentic-container:latest
# Initial build and test (smart about base, rebuilds cookbook)
./scripts/test-dockerfile.sh docs/cookbooks/python-cli/Dockerfile
# The script built: test-dockerfile-TIMESTAMP image
# Find it:
docker images | grep test-dockerfile
# Debug with existing image (no rebuild)
docker run --rm -it test-dockerfile-1234567890 bash
# When done iterating, run final test with cleanup
./scripts/test-dockerfile.sh docs/cookbooks/python-cli/Dockerfile --cleanup
# Instead of shell.sh (which rebuilds), use existing image:
docker run --rm -it test-standard:latest bash
# Or run a quick command:
docker run --rm test-standard:latest mise list
When adding complex commands to Dockerfile, test them first in existing image:
# Step 1: Test interactively to develop the command
docker run --rm -it --user root test-dev:latest bash
# Inside container, try commands until they work:
# $ mkdir -p /some/path
# $ ln -sf source target
# $ command --version
# $ exit
# Step 2: Test as one-liner (how Dockerfile RUN works)
docker run --rm --user root test-dev:latest bash -c '
mkdir -p /some/path && \
ln -sf source target && \
command --version
'
# Step 3: If successful, add to Dockerfile
RUN mkdir -p /some/path \
&& ln -sf source target
# Step 4: Rebuild and verify changes persisted
./scripts/test-dockerfile.sh dev
docker run --rm test-dev:latest command --version
Why This Matters:
Common Use Cases:
When packages or files are missing from final image but work in build stage:
# Step 1: Build the intermediate stage directly
./scripts/build-local.sh npm-globals-stage test-npm-globals:latest
# Step 2: Inspect what the stage actually contains
docker run --rm test-npm-globals:latest bash -c 'ls -la /path/to/expected/files'
# Step 3: Check for symlinks (Docker COPY follows them!)
docker run --rm test-npm-globals:latest bash -c 'ls -la /path/to/bin/'
# Step 4: Compare to final image
docker run --rm test-dev:latest bash -c 'ls -la /path/to/bin/'
# Step 5: Identify what's different
# - Symlinks become regular files when COPY'd
# - Permissions may change
# - Files might be in different locations
Common Multi-Stage Issues:
Solution Patterns:
CRITICAL: Deleting an image DOES NOT clear layer cache!
# This removes the image tag but layers persist:
docker rmi test-dev:latest
# Build will still show CACHED for unchanged layers:
./scripts/test-dockerfile.sh dev
# To actually clear layer cache:
docker builder prune -f
# Nuclear option (clears everything including unused images):
docker system prune -f && docker builder prune -f
Why This Matters:
Docker rebuilds from the first changed layer onward. Order matters:
# ✅ GOOD: Infrequently changing items first
FROM ubuntu:24.04
RUN apt-get update && apt-get install -y curl
ARG NODE_VERSION=24.8.0
RUN mise use -g node@${NODE_VERSION}
COPY scripts/ /usr/local/bin/ # Changes frequently
# ❌ BAD: Frequently changing items first
FROM ubuntu:24.04
COPY scripts/ /usr/local/bin/ # Changes frequently, invalidates all below
RUN apt-get update && apt-get install -y curl
# Watch build output for "CACHED" vs "RUN" steps
./scripts/build-local.sh standard agentic-container:test | grep -E '(CACHED|RUN|COPY)'
# If you see mostly CACHED, layer cache is working well
# If you see mostly RUN, something early in Dockerfile changed
Symptom: Build shows "CACHED" but you changed the Dockerfile Cause: Layer hash collision or cache from different branch/state
Solutions:
docker builder prune -f (fast, selective)Example Cache Bust:
# Before (keeps showing CACHED even after adding commands):
RUN mise use -g node@${NODE_VERSION} \
&& your-new-commands-here
# After (change comment to bust cache):
# v2: Added symlink creation
RUN mise use -g node@${NODE_VERSION} \
&& your-new-commands-here
Verifying Changes Persisted:
# Check if your changes made it into the image:
docker history test-dev:latest --no-trunc | grep "your-command"
# Or inspect the actual files:
docker run --rm test-dev:latest ls -la /path/to/your/files
test-standard:latest, test-dev:latesttest-dockerfile-TIMESTAMP (timestamped)# Default: Keep test images for inspection
./scripts/test-dockerfile.sh standard
docker run --rm -it test-standard:latest bash # Debug it
# Cleanup when done
docker rmi test-standard:latest
# Or use --cleanup flag (auto-removes after tests pass)
./scripts/test-dockerfile.sh standard --cleanup
Symptom: Added commands to Dockerfile but they don't seem to execute or changes don't persist
Debugging Steps:
# 1. Check if command is in image history
docker history test-dev:latest --no-trunc | grep "your-command"
# 2. If found, check if changes actually exist in image
docker run --rm test-dev:latest ls -la /path/to/expected/files
# 3. If not found or layer shows CACHED, try cache bust
# Edit Dockerfile: add/change a comment in the RUN command
# 4. Test the command manually first (Pattern 5)
docker run --rm --user root test-dev:latest bash -c 'your-command'
Common Causes:
&& chain (test commands individually)Symptom: Files exist in build stage but not in final multi-stage image
Debugging Steps:
# 1. Build and inspect the intermediate stage
./scripts/build-local.sh your-stage test-stage:latest
docker run --rm test-stage:latest ls -la /expected/path
# 2. Compare to final image
docker run --rm test-dev:latest ls -la /expected/path
# 3. Check if symlinks are involved
docker run --rm test-stage:latest bash -c 'ls -la /path/ | grep "^l"'
Common Causes:
Symptom: Modified Dockerfile but build output shows "CACHED" for your layer
Solutions:
# Option 1: Force cache bust with small change
# Add or modify a comment in the RUN command
# Option 2: Clear builder cache
docker builder prune -f
# Option 3: Verify your change is actually different
git diff Dockerfile # Did the change actually save?
Why This Happens:
./scripts/test-dockerfile.sh# Check what you have
docker images | grep -E '(agentic|test-)'
# Build what you need
./scripts/test-dockerfile.sh dev # Builds test-dev:latest
Symptoms:
Only as last resort:
# Nuclear option: clear all cache and rebuild
docker system prune -f && docker builder prune -f
# Rebuild from scratch (will take several minutes)
./scripts/test-dockerfile.sh dev
# Build base standard target
./scripts/build-local.sh standard agentic-container:latest
# Build dev target
./scripts/build-local.sh dev agentic-container:dev
# Build specific stage
./scripts/build-local.sh python-stage python-only:latest
# Test base target (rebuilds)
./scripts/test-dockerfile.sh standard
# Test with cleanup
./scripts/test-dockerfile.sh standard --cleanup
# Test cookbook
./scripts/test-dockerfile.sh docs/cookbooks/python-cli/Dockerfile
# CI mode (use pre-built image)
./scripts/test-dockerfile.sh standard test-standard:latest
# Using shell.sh (rebuilds)
./scripts/shell.sh standard
# Using existing image (no rebuild)
docker run --rm -it test-standard:latest bash
# Run a command in existing image
docker run --rm test-standard:latest python --version
# List all images
docker images | grep -E '(agentic|test-)'
# Remove test images
docker rmi $(docker images -q 'test-*')
# Check image age
docker image inspect agentic-container:latest --format '{{.Created}}'
# Check Dockerfile age
ls -l Dockerfile
# Inspect layer history
docker history test-dev:latest --no-trunc | grep "your-command"
# Test command manually as root
docker run --rm --user root test-dev:latest bash -c 'your-command'
# Interactive debugging session
docker run --rm -it --user root test-dev:latest bash
# Check if file exists in image
docker run --rm test-dev:latest ls -la /path/to/file
# Check for symlinks
docker run --rm test-dev:latest bash -c 'ls -la /path/ | grep "^l"'
# Compare files between stages
docker run --rm test-stage:latest ls -la /path
docker run --rm test-dev:latest ls -la /path
# Clear builder cache (recommended)
docker builder prune -f
# Clear all Docker cache (nuclear option)
docker system prune -f && docker builder prune -f
# Check builder cache size
docker system df
# Remove specific image (doesn't clear layers!)
docker rmi test-dev:latest
Need to work with Docker image?
├─ Developing new Dockerfile commands?
│ ├─ Step 1: Prototype in existing image (Pattern 5)
│ ├─ Step 2: Add to Dockerfile
│ └─ Step 3: Test with ./scripts/test-dockerfile.sh
│
├─ RUN command not working as expected?
│ ├─ Check: docker history IMAGE | grep "command"
│ ├─ Test manually: docker run --user root IMAGE bash -c 'command'
│ └─ If CACHED: Add comment to bust cache
│
├─ Files missing in final image?
│ ├─ Build intermediate stage: ./scripts/build-local.sh STAGE
│ ├─ Inspect: docker run STAGE-IMAGE ls -la /path
│ └─ Check for symlinks: ls -la | grep "^l"
│
├─ Build shows CACHED but you changed Dockerfile?
│ ├─ Try: Modify a comment in the RUN command
│ ├─ Or: docker builder prune -f
│ └─ Verify: docker history IMAGE --no-trunc
│
├─ Making Dockerfile changes?
│ ├─ Yes → Run test-dockerfile.sh (will rebuild with cache)
│ └─ No ↓
│
├─ Making goss test changes only?
│ ├─ Yes → Use existing image with docker run + volume mounts
│ └─ No ↓
│
├─ Need interactive shell?
│ ├─ Image exists? → docker run -it IMAGE bash
│ └─ No image → ./scripts/test-dockerfile.sh TARGET
│
├─ Testing if something works?
│ ├─ Image exists? → docker run IMAGE your-test-command
│ └─ No image → ./scripts/test-dockerfile.sh TARGET
│
└─ Just want to build?
└─ ./scripts/test-dockerfile.sh TARGET (preferred, includes tests)
└─ Or: ./scripts/build-local.sh TARGET TAG (build only)
Invoke this skill when:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
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...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
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...
Display project status, active tracks, and next actions
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.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience