← Cheat Sheets
Dockerfile Instructions
What each Dockerfile instruction does.
# Dockerfile Instructions
What each Dockerfile instruction does.
| Instruction | Purpose |
|---|---|
| `FROM` | Base image |
| `WORKDIR` | Set working directory |
| `COPY` | Copy files into the image |
| `RUN` | Run a command at build time |
| `ENV` | Set environment variable |
| `ARG` | Build-time variable |
| `EXPOSE` | Document a port |
| `CMD` | Default command (overridable) |
| `ENTRYPOINT` | Fixed executable |
| `USER` | Run as this user |
| `VOLUME` | Declare mount point |
| `HEALTHCHECK` | Container health test |
```dockerfile
FROM node:22-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 3000
USER node
CMD ["node", "server.js"]
```
Copy dependency files first so the install layer is cached.