Deploy and launch · Skill
Containerise an app with Docker
containerise-app-with-docker
Packages an app into a small, secure Docker image with a multi-stage Dockerfile - pinned slim base images, cached dependency layers, a .dockerignore, a non-root user and a health check - then builds and runs it locally. Use when the user wants to dockerise an app, write a Dockerfile, shrink a huge image, or run their app in a container.
Works with: Any AI Not yet model-tested; testing Jan 2027
Paste it into ChatGPT, Claude, Gemini or any AI chat, then tell it about your project. How it works
Install in Claude Code, Cursor or Codex (optional)
Only for AI coding tools that read skill folders. Run one line in a terminal, in your project folder. It downloads this skill's text files from TheSkillVault and nothing else; you can read them first with “View raw SKILL.md”.
Claude Code (all your projects)
curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/containerise-app-with-docker/raw' -o ~/'.claude/skills/containerise-app-with-docker/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/containerise-app-with-docker/files/LICENSE.txt' -o ~/'.claude/skills/containerise-app-with-docker/LICENSE.txt'Cursor (this project)
curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/containerise-app-with-docker/raw' -o '.cursor/skills/containerise-app-with-docker/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/containerise-app-with-docker/files/LICENSE.txt' -o '.cursor/skills/containerise-app-with-docker/LICENSE.txt'Codex and other Agent Skills tools (this project)
curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/containerise-app-with-docker/raw' -o '.agents/skills/containerise-app-with-docker/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/containerise-app-with-docker/files/LICENSE.txt' -o '.agents/skills/containerise-app-with-docker/LICENSE.txt'
Or connect the whole library over MCP
Add TheSkillVault to Cursor or add this to your app's MCP settings (read-only; help):
{
"mcpServers": {
"theskillvault": {
"url": "https://theskillvault.ai/mcp"
}
}
}A container packs your app and everything it needs into one image that runs the same everywhere. Multi-stage builds keep that image small.
When to use
- A host asks for a Docker image or a Dockerfile.
- "It works on my machine" keeps biting you.
- Your image is over 1 GB and slow to deploy.
Steps
- Add a
.dockerignorelistingnode_modules,.git,.env*, build output and logs. - Pick an official slim base with an exact tag, such as
node:22-slimorpython:3.12-slim. - Stage one ("deps"): copy only the lockfile and manifest, then install dependencies. This layer caches.
- Stage two ("build"): copy the source and run the build.
- Final stage: start from the slim base again and copy only the built output and production dependencies.
- Create or use a non-root user and switch to it with
USER. - Set
NODE_ENV=production(or the equivalent),EXPOSEthe port and add aHEALTHCHECKif your host uses it. - Build and run:
docker build -t myapp .thendocker run --env-file .env -p 3000:3000 myapp. - Check the size with
docker images myappand scan it withdocker scout cves myappor Trivy.
FROM node:22-slim AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM deps AS build
COPY . .
RUN npm run build && npm prune --omit=dev
FROM node:22-slim
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build --chown=node:node /app/node_modules ./node_modules
COPY --from=build --chown=node:node /app/dist ./dist
USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]
Gotchas
- Never
COPY .envor bake API keys into an image. Anyone with the image can read them. Pass secrets at run time. - Copying all source before installing dependencies breaks caching, so every build reinstalls.
latesttags change under you. Pin versions.- Alpine images are small but can break native modules. Slim images are the safer default.
Portability
Works with any language: swap the install and build commands for pip, Go or Maven. If you use Podman instead of Docker, the same Dockerfile works.
Example prompt
"Write a production Dockerfile for my Node API that is small, runs as non-root and keeps secrets out of the image."
Done when
- The image builds and the app runs with
docker run. - It runs as a non-root user and contains no
.envfile or keys. - The final image is far smaller than a single-stage build.
---
Adapted from "multi-stage-dockerfile" in github/awesome-copilot (MIT, Copyright GitHub, Inc.). See LICENSE.txt.
Bundled files
Licence
Adapted from GitHub awesome-copilot contributors (multi-stage-dockerfile) (Copyright GitHub, Inc.), MIT License. Adapted by TheSkillVault: turned a bullet checklist into numbered steps with an original Node example, a .dockerignore and run commands; added secrets handling, gotchas and done-when.
Licence: MIT License. Attribution when you reuse it: Based on work by GitHub awesome-copilot contributors (multi-stage-dockerfile) (Copyright GitHub, Inc., MIT License), https://github.com/github/awesome-copilot/tree/5269f7ea2d6c3a9bfda5ed878b6726cf509121fd/skills/multi-stage-dockerfile; adapted by TheSkillVault, https://theskillvault.ai