Install
$ agentstack add skill-cogni-ai-ou-cogni-ai-agent-skills-dockerfile Open-source listing, not yet scanned by AgentStack. Follow the source repository for install instructions.
Security review
⚠ Flagged1 finding(s); flagged for manual review. · v0.1.0 How review works →
- • Prompt-injection patterns
- • Secret / credential exfiltration
- • Dangerous shell & filesystem operations
- • Untrusted network calls
- • Known-malicious package signatures
- high Destructive filesystem operation.
What it can access
- ● Network access Used
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Skill: dockerfile
Create and maintain highly optimized, secure, and minimal Dockerfiles. Focus on strict deterministic builds, security compliance, and caching efficiency.
When to Use
- When writing, optimizing, or reviewing a
Dockerfilefor a new or existing service. - To reduce the image size or improve the layer caching efficiency of an existing Docker build.
- When auditing a
Dockerfilefor security compliance (e.g., non-root users, pinned bases).
When Not to Use
- When configuring local development environments that rely strictly on
devcontainer.jsonwithout custom Dockerfiles. - For managing runtime container orchestration (use
dockerordocker-composeinstead). - If the project relies on Cloud Native Buildpacks (CNB) rather than explicit Dockerfiles.
Common Pitfalls
- Leaking Secrets: Using
COPYorENVto handle build secrets instead of the secure--mount=type=secretdirective. - Late User Switching: Defining
USER nonrootbut forgetting tochownthe files copied from the builder stage, leading to permission denied errors at runtime. - Cache Busting: Placing rapidly changing instructions (like
COPY . .) before slow, static instructions (likenpm install), destroying layer cache efficiency on every code change.
Core Process
- Base Selection: Use official, minimal bases (e.g.,
alpine,distroless) with precise version tags or SHA256 pinning. - Dependency Layering: Copy manifests (e.g.,
package.json,go.mod) first, install dependencies, thenCOPYsource code to maximize cache hits. - Multi-Stage Builds: Separate build-time environments from runtime execution. Only copy compiled artifacts to the final stage.
- Layer Consolidation: Chain
RUNcommands with&&and clear package manager caches within the same layer. - Least Privilege: Define a non-root
USERbeforeENTRYPOINTorCMD.
Core Principles
- Determinism: Avoid
latesttags to prevent build drift and ensure reproducible environments. - Immutability: Treat the container filesystem as read-only. Mount volumes for mutable paths.
- Signal Handling: Use the
execJSON array form forENTRYPOINTandCMD(e.g.,["node", "app.js"]) instead of shell form to allow graceful termination (SIGTERM).
Commands / Usage Patterns
- Minimal Multi-Stage Pattern:
```dockerfile # Use specific version and digest for deterministic builds FROM golang:1.24.0-alpine3.21@sha256:e74d913cc537f546b946e685c84a98598ba93b4de1f762d0c353a4261a1d1052 AS builder WORKDIR /app COPY go.mod go.sum ./ RUN go mod download COPY . . # Force static build by disabling CGO and stripping symbols RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /server .
# Use a digest-pinned nonroot distroless base for maximum security FROM gcr.io/distroless/static-debian12:nonroot@sha256:e906328329624536768a49c9527ec3c3068e14e1a0b3554e2043697e88457e5e COPY --from=builder /server /server USER nonroot:nonroot EXPOSE 8080 ENTRYPOINT ["/server"] ```
- Deterministic Package Installation:
``dockerfile RUN apt-get update && \ apt-get install -y --no-install-recommends \ curl=7.88.1-10+deb12u8 \ jq=1.6-2.1 && \ rm -rf /var/lib/apt/lists/* ``
- Discovering Real-World Usage:
Use gh search to surface advanced Dockerfile patterns and community best practices directly from GitHub:
- Find multi-stage architecture examples (requires
ASkeyword):
gh search code "FROM" "AS" --language dockerfile --limit 5 --json repository,path,url
- Locate repository templates and guides (sorted by stars):
gh search repos "Dockerfile best practices" --sort stars --order desc --limit 5 --json fullName,description,url
Diagnostics and Troubleshooting
- Large Images: Inspect layer bloat with
docker historyor usedive. Watch for orphaned cache files. - Cache Misses: Ensure
COPY . .is positioned as late as possible. A single modified source file busts the cache for all subsequent steps. - Permission Denied: If a non-root user fails to execute, verify ownership of
WORKDIR, copied artifacts, and runtime directories. Crucial: Ownership must be fixed in the final image stage (e.g., usingCOPY --chownorRUN chownbefore switching toUSER), as permissions set in builder stages do not persist for files copied to the final runtime image. Distroless images may require fixing ownership in the builder if the final image lacks shell tools, or ideally usingCOPY --chown.
What to Avoid
- Avoid Root: Never omit the
USERdirective in a production image. - Avoid Shell Form: Do not write
ENTRYPOINT npm start. Using shell form spawns a/bin/shwrapper, breaking signal propagation. - Avoid Build Tools in Runtime: Never ship
gcc,make, or similar tools in the final image. - Avoid Baked Secrets: Never embed credentials using
ENVorCOPY. Use--mount=type=secretduring build or inject at runtime.
Related Skills
- docker:
You MUST load this skill when running, managing, or troubleshooting Docker containers and networks.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: Cogni-AI-OU
- Source: Cogni-AI-OU/cogni-ai-agent-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.