Loading...
Analyze Dockerfiles for security risks, layer cache invalidation, and image size bloat
Load common container recipes and anti-pattern examples
Paste or edit your container definition
Container runs as root by default. Create and switch to a non-root user (e.g., USER node or USER 1001) to prevent privilege escalation.
RUN addgroup -S appgroup && adduser -S appuser -G appgroup USER appuser
Base image "node:latest" uses the :latest or untagged version. Pin to a specific version or SHA digest for reproducible builds.
Pin to specific tag like "node:22-alpine"
Copying the full workspace before installing dependencies breaks Docker caching on any code edit.
COPY package.json package-lock.json ./ RUN npm ci COPY . .
FROM node:latest WORKDIR /app COPY . . RUN npm install EXPOSE 3000 CMD ["npm", "start"] # Best practice: run as non-root user USER node