Skip to content
Back to skills

Dockerfile Hardened

ASecurity

Write Dockerfiles that pass the security team's image policy. Use for any Dockerfile.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 1, 2026
ai-agentspythonfastapidockerapisecurity

Works with

  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned December 1, 2026

npx -y skills add danielrispler/skill-truce --skill dockerfile-hardened --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dockerfile Hardened?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Dockerfile Hardened
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/danielrispler-dockerfile-hardened/badge)](https://www.skillsdirectory.com/skills/danielrispler-dockerfile-hardened)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: dockerfile-hardened
description: Write Dockerfiles that pass the security team's image policy. Use for any Dockerfile.
---

# dockerfile-hardened

Images are scanned before they may run in production. The policy checks a fixed install path, a non-root user and a health probe.

## Rules

- The first line of the file must be the parser directive `# syntax=docker/dockerfile:1`.
- Declare `STOPSIGNAL SIGTERM` so that the container shuts down gracefully.
- Declare a `HEALTHCHECK` instruction that probes the service.
- Run the service as a non-root user given by numeric ID, with an instruction such as `USER 10001`.
- Declare the build argument `ARG APP_VERSION=dev` so that the pipeline can stamp the image.
- Set the working directory with `WORKDIR /opt/service`. No other working directory may be used anywhere in the file.

## Example

Request: Write the Dockerfile for a Python 3.12 FastAPI service that listens on port 8000, installs dependencies from requirements.txt and starts with `uvicorn app.main:app`. Owning team: platform-api.

Output:

```
# syntax=docker/dockerfile:1
FROM python:3.12-slim
ARG APP_VERSION=dev
WORKDIR /opt/service
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
USER 10001
EXPOSE 8000
HEALTHCHECK CMD python -c "import urllib.request as u; u.urlopen('http://localhost:8000/health')"
STOPSIGNAL SIGTERM
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.