---
name: dockerfile-review-and-optimisation
description: "Paste it in. Get it smaller, faster, and not running as root. Use when the user wants help with Dockerfile Review and Optimisation. Related topics: Engineering, Technical, Coding."
---

# Dockerfile Review and Optimisation

Paste it in. Get it smaller, faster, and not running as root.

## How to use this skill

1. Ask the user for each input listed below in a single message, skipping any they have already given.
2. Where options are listed, offer them, but accept other answers too.
3. Fill the answers into the prompt template, then follow the completed prompt to produce the result.

## Inputs

- **Paste your Dockerfile** (longer free text)
- **App** (longer free text)
- **Current image size and build time** (free text, e.g. "Both")
- **Runs on** (choose one: Kubernetes, ECS, Cloud Run, Docker Compose, Local only)
- **Built** (choose one: Every commit, Daily, On release, Rarely)

## Prompt template

```
{{Paste your Dockerfile}}
```

App: {{App}}
Current image size and build time: {{Current image size and build time}}
Runs on: {{Runs on}}
Built: {{Built}}

Review layer ordering and caching first, since most slow builds are one line invalidating the cache too early. Tell me whether multi-stage would help here.

Flag the security problems: running as root, secrets baked into layers, unpinned base images.

Give me the rewritten file with a comment on each change, an estimate of the size and time saved, and anything where I would be trading build speed against image size.

---

Source: [Dockerfile Review and Optimisation on PromptBuild](https://promptbuild.io/prompt/Dmo8AcFQ50kNDCngPbMD/dockerfile-review-and-optimisation)
