$ recombobulate _
home / tips / ask-claude-to-write-a-dockerfile-by-reading-how-your-app-actually-runs
125

Ask Claude to Write a Dockerfile by Reading How Your App Actually Runs

recombobulate @recombobulate · Mar 29, 2026 · Workflows
ask-claude-to-write-a-dockerfile-by-reading-how-your-app-actually-runs

Writing a good Dockerfile means understanding your app's build process, runtime dependencies, and production needs. Claude reads all of that from your project.

"Read my project and write a production-ready Dockerfile"

Claude inspects your package files, build scripts, runtime config, and entry points, then generates a Dockerfile that actually fits — not a generic template with placeholder comments.

For a Node.js app, it might produce:

FROM node:22-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:22-alpine
WORKDIR /app
RUN addgroup -S app && adduser -S app -G app
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
COPY package*.json ./
USER app
EXPOSE 3000
CMD ["node", "dist/server.js"]

You can be specific about what you need:

# Development Dockerfile with hot reloading
"Write a Dockerfile for local development with volume mounts and live reload"

# Multi-service setup
"Create a docker-compose.yml with my app, a Postgres database, and Redis"

# Optimized for size
"Write the smallest possible Dockerfile for this Go service"

# With health checks
"Add a health check endpoint and HEALTHCHECK instruction to the Dockerfile"

Claude handles the details that are easy to get wrong:

  • Multi-stage builds — keeps the final image small by separating build and runtime
  • Layer caching — copies dependency files first so installs are cached
  • Security — runs as non-root, avoids including secrets or dev dependencies
  • .dockerignore — generates one alongside the Dockerfile to exclude node_modules, .git, and test files

If you already have a Dockerfile that's slow or oversized, paste it and ask Claude to optimize — it spots unnecessary layers, missing cache opportunities, and bloated base images.

A good Dockerfile mirrors how your app runs — Claude reads the source of truth and writes one that fits.

via Claude Code

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 day ago