- Home
- Skills
- DevOps & Cloud
- Docker Compose Security Hardener
Works with the AI Agents you already use
Docker Compose Security Hardener
Audit and refactor Docker and Compose files to enforce production-grade security, non-root users, and network isolation.
$9.90
Docker Compose Security Hardener
Example session with this skill installed
Audit and harden this Dockerfile: FROM node:latest\nCOPY . /app\nWORKDIR /app\nRUN npm install\nEXPOSE 3000\nCMD ["node", "index.js"]
- Read your context and instructions
- Compiled the docker compose security
I have completed the security audit of your Dockerfile. The original configuration had 1 Critical, 1 High, and 2 Medium severity findings, primarily revolving around root execution and unpinned base images.
🔍 Security Audit Report
Summary
- Critical: 1 | High: 1 | Medium: 2 | Low: 0
Findings
[CRITICAL] Root User Execution
- Location: Line 6
Risk: The container runs as root by default. If the application is compromised, the attacker gains root privileges within the container.
- Fix: Create a non-privileged system user and switch to it using the
USERinstruction.
[HIGH] Unpinned Image Tag
- Location: Line 1
Risk: Using node:latest leads to non-deterministic builds and potential injection of breaking changes or vulnerabilities.
- Fix: Pin the image to a specific version and SHA256 digest.
Hardened Dockerfile
# Use specific version and SHA256 for build-time integrity
FROM node:20.11.0-slim@sha256:88995d3c8f85f54316d26210f845d8b74a383438257f89d53c5f49b1a5e173e6 AS build
# Set workdir
WORKDIR /app
# Copy package files separately to leverage layer caching
COPY package*.json ./
RUN npm ci --only=production
# Copy application source
COPY . .
# Production stage
FROM node:20.11.0-slim@sha256:88995d3c8f85f54316d26210f845d8b74a383438257f89d53c5f49b1a5e173e6
WORKDIR /app
# Create a dedicated non-privileged system user
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nodejs --ingroup nodejs
# Copy only necessary files from build stage
COPY --from=build --chown=nodejs:nodejs /app/node_modules ./node_modules
COPY --from=build --chown=nodejs:nodejs /app .
# Switch to non-root user
USER 1001
EXPOSE 3000
# Healthcheck for observability
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (r) => r.statusCode === 200 ? process.exit(0) : process.exit(1))"
CMD ["node", "index.js"]
Next steps
- Verify the
node:20.11.0-slimdigest matches your organization's approved registry. - Ensure your
index.jsimplements a/healthendpoint for the healthcheck to monitor. - Implement resource limits in your
docker-compose.ymlwhen deploying this image.
Connects securely to your tools. The creator never sees your data.
About this skill
Standard container setups often leak sensitive host data, run as root by default, or expose databases to the public internet. This skill provides an automated security audit and refactoring engine for container infrastructure. It transforms insecure development files into hardened, production-ready assets by enforcing strict isolation and resource constraints.
What it does
- Vulnerability scanning identifies critical risks like root execution, privileged modes, and docker.sock mounts.
- Automated refactoring rewrites Dockerfiles and Compose files to inject security best practices.
- Network isolation segments services into scoped networks and prevents accidental public port exposure.
- Resource management enforces CPU/memory limits and healthchecks to prevent DoS and ensure observability.
- Secret sanitation migrates hardcoded credentials to secure environment files or Docker Secrets.
How it works
- Audit phase where you provide a Dockerfile or docker-compose.yml for a tiered severity scan.
- Report generation detailing specific risks, locations, and remediation steps.
- Hardened output producing the full, refactored code with inline security explanations.
- Verification checklist confirming all mandatory production rules are met.
Frameworks & tools
Works with Docker, Docker Compose, and OCI-compliant container specifications.
Why this beats prompting it yourself
Generic prompts often miss subtle risks like floating image tags or missing read-only flags on volume mounts. This skill follows a strict "Zero Tolerance" policy for privileged execution and network leakage that basic LLM instructions frequently overlook.
Use cases
- Auditing a legacy Dockerfile before a production release.
- Hardening a third-party docker-compose.yml for internal hosting.
- Creating a secure, non-root container template for a new microservice.
- Implementing resource bounds and healthchecks across a multi-service stack.
Known limitations
Does not perform runtime behavioral analysis or scan binary application code inside the image. Requires manual entry of specific SHA256 digests if not already provided in the source.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed today